Make jupyter test notebook py2/3 compatible

Change-Id: I2649728d5a240e0f476f71742f4e950b4c68e643
This commit is contained in:
Tim Burke 2019-11-08 05:35:48 +00:00 committed by Tim Burke
parent a4087219c7
commit 9f2e9b20b8
2 changed files with 13 additions and 17 deletions

@ -83,8 +83,6 @@ class TestJupyterExcecution(unittest.TestCase):
return output_text_list
def test_notebook(self):
if six.PY3:
self.skipTest("notebook incompatible with python3")
test_path = os.path.abspath(__file__)
test_dir = os.path.dirname(test_path)
original_notebook = os.path.join(test_dir, 'test_notebook.ipynb')

@ -60,7 +60,7 @@
" out_files[0].set_metadata(metadata)\n",
"\n",
" self.logger.debug('Start to return object data')\n",
" content = ''\n",
" content = b''\n",
" while True:\n",
" buf = in_files[0].read(16)\n",
" if not buf:\n",
@ -87,7 +87,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{u'x-object-meta-storlet-language': u'python', u'x-trans-id': u'tx39de631f32cf42d58f407-0058f89455', u'x-object-meta-storlet-main': u'test.TestStorlet', u'transfer-encoding': u'chunked', u'x-object-meta-storlet-interface-version': u'1.0', u'x-object-meta-storlet-object-metadata': u'no', u'x-object-meta-storlet_execution_path': u'/home/swift/test.TestStorlet', u'last-modified': u'Thu, 20 Apr 2017 10:58:29 GMT', u'etag': u'0f0f7e5d45e0c97e159dbee5eb569ae0', u'x-timestamp': u'1492685908.66304', u'x-object-meta-color': u'red', u'date': u'Thu, 20 Apr 2017 10:58:29 GMT', u'x-openstack-request-id': u'tx39de631f32cf42d58f407-0058f89455', u'content-type': u'application/octet-stream', u'accept-ranges': u'bytes'}\n",
"{u'x-object-meta-storlet-language': u'python', u'x-trans-id': u'tx39de631f32cf42d58f407-0058f89455', u'x-object-meta-storlet-main': u'test.TestStorlet', u'transfer-encoding': u'chunked', u'x-object-meta-storlet-interface-version': u'1.0', u'x-object-meta-storlet-object-metadata': u'no', u'x-object-meta-storlet_execution_path': u'/home/swift/test.TestStorlet', u'last-modified': u'Thu, 20 Apr 2017 10:58:29 GMT', u'etag': u'43106d4a48a1f33745e11bd71596d8c4', u'x-timestamp': u'1492685908.66304', u'x-object-meta-color': u'red', u'date': u'Thu, 20 Apr 2017 10:58:29 GMT', u'x-openstack-request-id': u'tx39de631f32cf42d58f407-0058f89455', u'content-type': u'application/octet-stream', u'accept-ranges': u'bytes'}\n",
"\n",
"class TestStorlet(object):\n",
" def __init__(self, logger):\n",
@ -107,7 +107,7 @@
" out_files[0].set_metadata(metadata)\n",
"\n",
" self.logger.debug('Start to return object data')\n",
" content = ''\n",
" content = b''\n",
" while True:\n",
" buf = in_files[0].read(16)\n",
" if not buf:\n",
@ -125,8 +125,8 @@
"source": [
"myparams = {'color' : 'red'}\n",
"%get --storlet test.py --input path:/storlet/test.py -i myparams -o myresult\n",
"print myresult.headers\n",
"print myresult.content"
"print(myresult.headers)\n",
"print(myresult.content)"
]
},
{
@ -142,15 +142,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{u'content-length': u'0', u'x-storlet-generated-from-last-modified': u'Thu, 20 Apr 2017 10:58:29 GMT', u'x-storlet-generated-from-account': u'AUTH_6dbd182dfa9f4ad6ace88992683ee483', u'last-modified': u'Thu, 20 Apr 2017 10:58:32 GMT', u'etag': u'0f0f7e5d45e0c97e159dbee5eb569ae0', u'x-trans-id': u'tx8cc66cd8cda643508bee7-0058f89457', u'date': u'Thu, 20 Apr 2017 10:58:31 GMT', u'content-type': u'text/html; charset=UTF-8', u'x-openstack-request-id': u'tx8cc66cd8cda643508bee7-0058f89457', u'x-storlet-generated-from': u'storlet/test.py'}\n",
"{u'content-length': u'0', u'x-storlet-generated-from-last-modified': u'Thu, 20 Apr 2017 10:58:29 GMT', u'x-storlet-generated-from-account': u'AUTH_6dbd182dfa9f4ad6ace88992683ee483', u'last-modified': u'Thu, 20 Apr 2017 10:58:32 GMT', u'etag': u'43106d4a48a1f33745e11bd71596d8c4', u'x-trans-id': u'tx8cc66cd8cda643508bee7-0058f89457', u'date': u'Thu, 20 Apr 2017 10:58:31 GMT', u'content-type': u'text/html; charset=UTF-8', u'x-openstack-request-id': u'tx8cc66cd8cda643508bee7-0058f89457', u'x-storlet-generated-from': u'storlet/test.py'}\n",
"201\n"
]
}
],
"source": [
"%copy --storlet test.py --input path:/storlet/test.py --output path:/log/test.py -i myparams -o myresult\n",
"print myresult.headers\n",
"print myresult.status"
"print(myresult.headers)\n",
"print(myresult.status)"
]
},
{
@ -181,8 +181,8 @@
" for x in range(10):\n",
" f.write('INFO: sapmle log line')\n",
"%put --storlet test.py --input /tmp/tmpZl6teg/storlet_invoke.log --output path:/log/onvoke.log -i myparams -o myresult\n",
"print myresult.headers\n",
"print myresult.status"
"print(myresult.headers)\n",
"print(myresult.status)"
]
},
{
@ -199,9 +199,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python",
"language": "python",
"name": "python2"
"name": "python"
},
"language_info": {
"codemirror_mode": {
@ -211,9 +211,7 @@
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
"nbconvert_exporter": "python"
}
},
"nbformat": 4,