diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index fdc650edf..45b8c10e7 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -60,34 +60,6 @@ def project_teardown(): return proj -@pytest.fixture(scope="function") -def project_function(request, syn): - """ - Create a project to be shared at a function level scope. - """ - - # Make one project - proj = syn.store( - Project( - name="integration_test_project_for_individual_functions_" - + str(uuid.uuid4()) - ) - ) - - # set the working directory to a temp directory - _old_working_directory = os.getcwd() - working_directory = tempfile.mkdtemp(prefix="someTestFolder") - os.chdir(working_directory) - - def project_teardown(): - _cleanup(syn, [working_directory, proj]) - os.chdir(_old_working_directory) - - request.addfinalizer(project_teardown) - - return proj - - @pytest.fixture(scope="module") def schedule_for_cleanup(request, syn): """Returns a closure that takes an item that should be scheduled for cleanup. diff --git a/tests/integration/synapseclient/core/test_external_storage.py b/tests/integration/synapseclient/core/test_external_storage.py index dc5c5f832..f32c043df 100644 --- a/tests/integration/synapseclient/core/test_external_storage.py +++ b/tests/integration/synapseclient/core/test_external_storage.py @@ -52,8 +52,8 @@ def _syn(self, syn: Synapse): self.syn = syn @pytest.fixture(autouse=True) - def _project(self, project_function: Project): - self.project = project_function + def _project(self, project: Project): + self.project = project @classmethod def _make_temp_file(cls, contents=None, **kwargs): diff --git a/tests/integration/synapseclient/core/upload/test_multipart_upload.py b/tests/integration/synapseclient/core/upload/test_multipart_upload.py index b0781e41e..29b6ed7d2 100644 --- a/tests/integration/synapseclient/core/upload/test_multipart_upload.py +++ b/tests/integration/synapseclient/core/upload/test_multipart_upload.py @@ -24,14 +24,14 @@ @pytest.mark.flaky(reruns=3, only_rerun=["SynapseHTTPError"]) -def test_round_trip(syn: Synapse, project_function: Project, schedule_for_cleanup): +def test_round_trip(syn: Synapse, project: Project, schedule_for_cleanup): fhid = None filepath = utils.make_bogus_binary_file(MIN_PART_SIZE + 777771) try: fhid = multipart_upload_file(syn, filepath) # Download the file and compare it with the original - junk = File(parent=project_function, dataFileHandleId=fhid) + junk = File(parent=project, dataFileHandleId=fhid) junk.properties.update(syn._createEntity(junk.properties)) (tmp_f, tmp_path) = tempfile.mkstemp() schedule_for_cleanup(tmp_path) diff --git a/tests/integration/synapseclient/integration_test_Entity.py b/tests/integration/synapseclient/integration_test_Entity.py index 8a98f8cd5..e04939b33 100644 --- a/tests/integration/synapseclient/integration_test_Entity.py +++ b/tests/integration/synapseclient/integration_test_Entity.py @@ -388,11 +388,11 @@ def test_store_activity(syn, project, schedule_for_cleanup): assert honking["id"] == honking2["id"] -def test_store_isRestricted_flag(syn, project_function, schedule_for_cleanup): +def test_store_isRestricted_flag(syn, project, schedule_for_cleanup): # Store a file with access requirements path = utils.make_bogus_binary_file() schedule_for_cleanup(path) - entity = File(path, name="Secret human data", parent=project_function) + entity = File(path, name="Secret human data", parent=project) # We don't want to spam ACT with test emails with patch( diff --git a/tests/integration/synapseclient/test_command_line_client.py b/tests/integration/synapseclient/test_command_line_client.py index cb42a5318..9566d5f17 100644 --- a/tests/integration/synapseclient/test_command_line_client.py +++ b/tests/integration/synapseclient/test_command_line_client.py @@ -31,12 +31,12 @@ from io import StringIO -@pytest.fixture(scope="function") -def test_state(syn, project_function, schedule_for_cleanup): +@pytest.fixture(scope="module") +def test_state(syn: Synapse, project: Project, schedule_for_cleanup): class State: def __init__(self): self.syn = syn - self.project = project_function + self.project = project self.schedule_for_cleanup = schedule_for_cleanup self.parser = cmdline.build_parser() self.upload_filename = _create_temp_file_with_cleanup(schedule_for_cleanup) diff --git a/tests/integration/synapseclient/test_tables.py b/tests/integration/synapseclient/test_tables.py index aa2969e19..6456a176a 100644 --- a/tests/integration/synapseclient/test_tables.py +++ b/tests/integration/synapseclient/test_tables.py @@ -47,11 +47,11 @@ def revert_timeout(): def test_create_and_update_file_view( - syn: Synapse, project_function: Project, schedule_for_cleanup + syn: Synapse, project: Project, schedule_for_cleanup ): # Create a folder folder = Folder( - str(uuid.uuid4()), parent=project_function, description="creating a file-view" + str(uuid.uuid4()), parent=project, description="creating a file-view" ) folder = syn.store(folder) @@ -90,7 +90,7 @@ def test_create_and_update_file_view( addAnnotationColumns=False, type="file", columns=my_added_cols, - parent=project_function, + parent=project, ) entity_view = syn.store(entity_view) @@ -544,12 +544,10 @@ def test_synapse_integer_columns_with_missing_values_from_dataframe( assert_frame_equal(df, df2) -def test_store_table_datetime(syn, project_function): +def test_store_table_datetime(syn, project): current_datetime = datetime.fromtimestamp(round(time.time(), 3)) schema = syn.store( - Schema( - "testTable", [Column(name="testerino", columnType="DATE")], project_function - ) + Schema("testTable", [Column(name="testerino", columnType="DATE")], project) ) rowset = RowSet(rows=[Row([current_datetime])], schema=schema) syn.store(Table(schema, rowset)) diff --git a/tests/integration/synapseclient/test_wikis.py b/tests/integration/synapseclient/test_wikis.py index 1a5b1c4e1..0a16574cc 100644 --- a/tests/integration/synapseclient/test_wikis.py +++ b/tests/integration/synapseclient/test_wikis.py @@ -9,7 +9,7 @@ import synapseclient.core.utils as utils -def test_wikiAttachment(syn: Synapse, project_function: Project, schedule_for_cleanup): +def test_wikiAttachment(syn: Synapse, project: Project, schedule_for_cleanup): # Upload a file to be attached to a Wiki filename = utils.make_bogus_data_file() attachname = utils.make_bogus_data_file() @@ -26,7 +26,7 @@ def test_wikiAttachment(syn: Synapse, project_function: Project, schedule_for_cl Blabber jabber blah blah boo. """ wiki = Wiki( - owner=project_function, + owner=project, title="A Test Wiki", markdown=md, fileHandles=[fileHandle["id"]], @@ -36,7 +36,7 @@ def test_wikiAttachment(syn: Synapse, project_function: Project, schedule_for_cl # Create a Wiki sub-page subwiki = Wiki( - owner=project_function, + owner=project, title="A sub-wiki", markdown="nothing", parentWikiId=wiki.id, @@ -44,7 +44,7 @@ def test_wikiAttachment(syn: Synapse, project_function: Project, schedule_for_cl subwiki = syn.store(subwiki) # Retrieve the root Wiki from Synapse - wiki2 = syn.getWiki(project_function) + wiki2 = syn.getWiki(project) # due to the new wiki api, we'll get back some new properties, # namely markdownFileHandleId and markdown_path, so only compare # properties that are in the first object @@ -52,7 +52,7 @@ def test_wikiAttachment(syn: Synapse, project_function: Project, schedule_for_cl assert wiki[property_name] == wiki2[property_name] # Retrieve the sub Wiki from Synapse - wiki2 = syn.getWiki(project_function, subpageId=subwiki.id) + wiki2 = syn.getWiki(project, subpageId=subwiki.id) for property_name in wiki: assert subwiki[property_name] == wiki2[property_name] @@ -60,12 +60,12 @@ def test_wikiAttachment(syn: Synapse, project_function: Project, schedule_for_cl wiki["title"] = "A New Title" wiki["markdown"] = wiki["markdown"] + "\nNew stuff here!!!\n" syn.store(wiki) - wiki = syn.getWiki(project_function) + wiki = syn.getWiki(project) assert wiki["title"] == "A New Title" assert wiki["markdown"].endswith("\nNew stuff here!!!\n") # Check the Wiki's metadata - headers = syn.getWikiHeaders(project_function) + headers = syn.getWikiHeaders(project) assert len(headers) == 2 assert headers[0]["title"] in (wiki["title"], subwiki["title"]) @@ -76,15 +76,15 @@ def test_wikiAttachment(syn: Synapse, project_function: Project, schedule_for_cl syn.delete(subwiki) syn.delete(wiki) - pytest.raises(SynapseHTTPError, syn.getWiki, project_function) + pytest.raises(SynapseHTTPError, syn.getWiki, project) -def test_create_or_update_wiki(syn, project_function): +def test_create_or_update_wiki(syn, project): # create wiki once syn.store( Wiki( title="This is the title", - owner=project_function, + owner=project, markdown="#Wikis are OK\n\nBlabber jabber blah blah blither blather bonk!", ) ) @@ -94,7 +94,7 @@ def test_create_or_update_wiki(syn, project_function): wiki = syn.store( Wiki( title=new_title, - owner=project_function, + owner=project, markdown="#Wikis are awesome\n\nNew babble boo flabble gibber wiggle sproing!", ), createOrUpdate=True, diff --git a/tests/integration/synapseutils/test_synapseutils_sync.py b/tests/integration/synapseutils/test_synapseutils_sync.py index 4c638b5a4..b723a4265 100644 --- a/tests/integration/synapseutils/test_synapseutils_sync.py +++ b/tests/integration/synapseutils/test_synapseutils_sync.py @@ -15,7 +15,7 @@ from tests.integration import QUERY_TIMEOUT_SEC -@pytest.fixture(scope="function", autouse=True) +@pytest.fixture(scope="module", autouse=True) def test_state(syn: Synapse, schedule_for_cleanup): class TestState: def __init__(self):