Skip to content

Commit 4441e48

Browse files
committed
Make test filenames unique
1 parent 62c90b8 commit 4441e48

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

singlestoredb/tests/test_management.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,16 @@ def tearDownClass(cls):
397397
def test_upload_file(self):
398398
st = self.wg.stage
399399

400+
upload_test_sql = f'upload_test_{id(self)}.sql'
401+
upload_test2_sql = f'upload_test2_{id(self)}.sql'
402+
400403
root = st.info('/')
401404
assert str(root.path) == '/'
402405
assert root.type == 'directory'
403406

404407
# Upload file
405-
f = st.upload_file(TEST_DIR / 'test.sql', 'upload_test.sql')
406-
assert str(f.path) == 'upload_test.sql'
408+
f = st.upload_file(TEST_DIR / 'test.sql', upload_test_sql)
409+
assert str(f.path) == upload_test_sql
407410
assert f.type == 'file'
408411

409412
# Download and compare to original
@@ -412,15 +415,15 @@ def test_upload_file(self):
412415

413416
# Make sure we can't overwrite
414417
with self.assertRaises(OSError):
415-
st.upload_file(TEST_DIR / 'test.sql', 'upload_test.sql')
418+
st.upload_file(TEST_DIR / 'test.sql', upload_test_sql)
416419

417420
# Force overwrite with new content; use file object this time
418421
f = st.upload_file(
419422
open(TEST_DIR / 'test2.sql', 'r'),
420-
'upload_test.sql',
423+
upload_test_sql,
421424
overwrite=True,
422425
)
423-
assert str(f.path) == 'upload_test.sql'
426+
assert str(f.path) == upload_test_sql
424427
assert f.type == 'file'
425428

426429
# Verify new content
@@ -442,9 +445,9 @@ def test_upload_file(self):
442445
# Write file into folder
443446
f = st.upload_file(
444447
TEST_DIR / 'test2.sql',
445-
os.path.join(lib.path, 'upload_test2.sql'),
448+
os.path.join(lib.path, upload_test2_sql),
446449
)
447-
assert str(f.path) == 'lib/upload_test2.sql'
450+
assert str(f.path) == 'lib/' + upload_test2_sql
448451
assert f.type == 'file'
449452

450453
def test_open(self):
@@ -1061,6 +1064,8 @@ def tearDownClass(cls):
10611064
cls.shared_space = None
10621065

10631066
def test_upload_file(self):
1067+
upload_test_ipynb = f'upload_test_{id(self)}.ipynb'
1068+
10641069
for space in [self.personal_space, self.shared_space]:
10651070
root = space.info('/')
10661071
assert str(root.path) == '/'
@@ -1069,9 +1074,9 @@ def test_upload_file(self):
10691074
# Upload files
10701075
f = space.upload_file(
10711076
TEST_DIR / 'test.ipynb',
1072-
'upload_test.ipynb',
1077+
upload_test_ipynb,
10731078
)
1074-
assert str(f.path) == 'upload_test.ipynb'
1079+
assert str(f.path) == upload_test_ipynb
10751080
assert f.type == 'notebook'
10761081

10771082
# Download and compare to original
@@ -1082,15 +1087,15 @@ def test_upload_file(self):
10821087
with self.assertRaises(OSError):
10831088
space.upload_file(
10841089
TEST_DIR / 'test.ipynb',
1085-
'upload_test.ipynb',
1090+
upload_test_ipynb,
10861091
)
10871092

10881093
# Force overwrite with new content
10891094
f = space.upload_file(
10901095
TEST_DIR / 'test2.ipynb',
1091-
'upload_test.ipynb', overwrite=True,
1096+
upload_test_ipynb, overwrite=True,
10921097
)
1093-
assert str(f.path) == 'upload_test.ipynb'
1098+
assert str(f.path) == upload_test_ipynb
10941099
assert f.type == 'notebook'
10951100

10961101
# Verify new content
@@ -1102,9 +1107,11 @@ def test_upload_file(self):
11021107
space.upload_folder(TEST_DIR, 'test')
11031108

11041109
# Cleanup
1105-
space.remove('upload_test.ipynb')
1110+
space.remove(upload_test_ipynb)
11061111

11071112
def test_upload_file_io(self):
1113+
upload_test_ipynb = f'upload_test_{id(self)}.ipynb'
1114+
11081115
for space in [self.personal_space, self.shared_space]:
11091116
root = space.info('/')
11101117
assert str(root.path) == '/'
@@ -1113,9 +1120,9 @@ def test_upload_file_io(self):
11131120
# Upload files
11141121
f = space.upload_file(
11151122
open(TEST_DIR / 'test.ipynb', 'r'),
1116-
'upload_test.ipynb',
1123+
upload_test_ipynb,
11171124
)
1118-
assert str(f.path) == 'upload_test.ipynb'
1125+
assert str(f.path) == upload_test_ipynb
11191126
assert f.type == 'notebook'
11201127

11211128
# Download and compare to original
@@ -1126,15 +1133,15 @@ def test_upload_file_io(self):
11261133
with self.assertRaises(OSError):
11271134
space.upload_file(
11281135
open(TEST_DIR / 'test.ipynb', 'r'),
1129-
'upload_test.ipynb',
1136+
upload_test_ipynb,
11301137
)
11311138

11321139
# Force overwrite with new content
11331140
f = space.upload_file(
11341141
open(TEST_DIR / 'test2.ipynb', 'r'),
1135-
'upload_test.ipynb', overwrite=True,
1142+
upload_test_ipynb, overwrite=True,
11361143
)
1137-
assert str(f.path) == 'upload_test.ipynb'
1144+
assert str(f.path) == upload_test_ipynb
11381145
assert f.type == 'notebook'
11391146

11401147
# Verify new content
@@ -1146,7 +1153,7 @@ def test_upload_file_io(self):
11461153
space.upload_folder(TEST_DIR, 'test')
11471154

11481155
# Cleanup
1149-
space.remove('upload_test.ipynb')
1156+
space.remove(upload_test_ipynb)
11501157

11511158
def test_open(self):
11521159
for space in [self.personal_space, self.shared_space]:

0 commit comments

Comments
 (0)