diff --git a/gufe/tests/test_alchemicalnetwork.py b/gufe/tests/test_alchemicalnetwork.py index 2fefdf7b..ef148bac 100644 --- a/gufe/tests/test_alchemicalnetwork.py +++ b/gufe/tests/test_alchemicalnetwork.py @@ -13,8 +13,7 @@ class TestAlchemicalNetwork(GufeTokenizableTestsMixin): cls = AlchemicalNetwork - key = "AlchemicalNetwork-a6869a43fc26ab0b159dfee489616109" - repr = "" + repr = None @pytest.fixture def instance(self, benzene_variants_star_map): diff --git a/gufe/tests/test_chemicalsystem.py b/gufe/tests/test_chemicalsystem.py index 73c05cf1..661ab19c 100644 --- a/gufe/tests/test_chemicalsystem.py +++ b/gufe/tests/test_chemicalsystem.py @@ -118,7 +118,6 @@ def test_sorting(solvated_complex, solvated_ligand): class TestChemicalSystem(GufeTokenizableTestsMixin): cls = ChemicalSystem - key = "ChemicalSystem-92176395ceb86ecd7787ce2585b24218" repr = "ChemicalSystem(name=, components={'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)})" @pytest.fixture diff --git a/gufe/tests/test_ligand_network.py b/gufe/tests/test_ligand_network.py index a81a0888..ff6f4d48 100644 --- a/gufe/tests/test_ligand_network.py +++ b/gufe/tests/test_ligand_network.py @@ -129,8 +129,7 @@ def network_container( class TestLigandNetwork(GufeTokenizableTestsMixin): cls = LigandNetwork - key = "LigandNetwork-c597016564f85a3c42445bd1dabd91b3" - repr = "" + repr = None @pytest.fixture def instance(self, simple_network): diff --git a/gufe/tests/test_ligandatommapping.py b/gufe/tests/test_ligandatommapping.py index 17a564bd..93809ac7 100644 --- a/gufe/tests/test_ligandatommapping.py +++ b/gufe/tests/test_ligandatommapping.py @@ -275,7 +275,6 @@ def test_too_small_B(self, molA, molB): class TestLigandAtomMapping(GufeTokenizableTestsMixin): cls = LigandAtomMapping repr = "LigandAtomMapping(componentA=SmallMoleculeComponent(name=), componentB=SmallMoleculeComponent(name=), componentA_to_componentB={0: 0, 1: 1}, annotations={'foo': 'bar'})" - key = "LigandAtomMapping-2c0aae226e3f69d2d1cf429abaefdb5b" @pytest.fixture def instance(self, annotated_simple_mapping): diff --git a/gufe/tests/test_mapping.py b/gufe/tests/test_mapping.py index c09c4f4f..cb8c7370 100644 --- a/gufe/tests/test_mapping.py +++ b/gufe/tests/test_mapping.py @@ -47,7 +47,6 @@ def componentB_unique(self): class TestMappingAbstractClass(GufeTokenizableTestsMixin): cls = ExampleMapping - key = 'ExampleMapping-ea9e102cdfddb0e243bde58074dd729c' repr = None @pytest.fixture diff --git a/gufe/tests/test_proteincomponent.py b/gufe/tests/test_proteincomponent.py index 934095a7..63d5b406 100644 --- a/gufe/tests/test_proteincomponent.py +++ b/gufe/tests/test_proteincomponent.py @@ -87,7 +87,6 @@ def assert_topology_equal(ref_top, top): class TestProteinComponent(GufeTokenizableTestsMixin): cls = ProteinComponent - key = "ProteinComponent-089f72c9fa2c9c18d53308038eeab5c9" repr = "ProteinComponent(name=Steve)" @pytest.fixture diff --git a/gufe/tests/test_protocol.py b/gufe/tests/test_protocol.py index 8795e665..4c44418f 100644 --- a/gufe/tests/test_protocol.py +++ b/gufe/tests/test_protocol.py @@ -203,8 +203,8 @@ def _create( class TestProtocol(GufeTokenizableTestsMixin): cls = DummyProtocol - key = "DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa" - repr = "" + repr = None + @pytest.fixture def instance(self): return DummyProtocol(settings=DummyProtocol.default_settings()) @@ -374,7 +374,6 @@ def test_key_stable(self, instance): class TestProtocolDAG(ProtocolDAGTestsMixin): cls = ProtocolDAG - key = None repr = None @pytest.fixture @@ -384,7 +383,6 @@ def instance(self, protocol_dag): class TestProtocolDAGResult(ProtocolDAGTestsMixin): cls = ProtocolDAGResult - key = None repr = None @pytest.fixture @@ -436,7 +434,6 @@ def test_protocol_unit_successes(self, instance: ProtocolDAGResult): class TestProtocolDAGResultFailure(ProtocolDAGTestsMixin): cls = ProtocolDAGResult - key = None repr = None @pytest.fixture @@ -466,7 +463,6 @@ def test_protocol_unit_failure_traceback(self, instance: ProtocolDAGResult): class TestProtocolUnit(GufeTokenizableTestsMixin): cls = SimulationUnit - key = None repr = None @pytest.fixture diff --git a/gufe/tests/test_protocolresult.py b/gufe/tests/test_protocolresult.py index 03833f75..4746906b 100644 --- a/gufe/tests/test_protocolresult.py +++ b/gufe/tests/test_protocolresult.py @@ -17,8 +17,7 @@ def get_uncertainty(self): class TestProtocolResult(GufeTokenizableTestsMixin): cls = DummyProtocolResult - key = 'DummyProtocolResult-b7b854b39c1e37feabec58b4000680a0' - repr = f'<{key}>' + repr = None @pytest.fixture def instance(self): diff --git a/gufe/tests/test_serialization_migration.py b/gufe/tests/test_serialization_migration.py index eb784fab..3e664252 100644 --- a/gufe/tests/test_serialization_migration.py +++ b/gufe/tests/test_serialization_migration.py @@ -176,21 +176,18 @@ class TestKeyAdded(MigrationTester): cls = KeyAdded input_dict = _SERIALIZED_OLD kwargs = {"foo": "foo", "bar": "bar", "qux": 10} - key = "KeyAdded-43d61e49c793a863b8b4f96b0e0b2876" class TestKeyRemoved(MigrationTester): cls = KeyRemoved input_dict = _SERIALIZED_OLD kwargs = {"foo": "foo"} - key = "KeyRemoved-93a689cdf75976b83507e4d1ded1ad7b" class TestKeyRenamed(MigrationTester): cls = KeyRenamed input_dict = _SERIALIZED_OLD kwargs = {"foo": "foo", "baz": "bar"} - key = "KeyRenamed-55860190714f16df7b9b6aab47346619" # for some reason, we'll move the child from belonging to the son to @@ -256,7 +253,6 @@ class TestNestedKeyMoved(MigrationTester): kwargs = { 'settings': {'son': {}, 'daughter': {'daughter_child': 10}} } - key = "Grandparent-0e2ea10e853d7ac730e7b2ae477a3801" @pytest.fixture def instance(self): diff --git a/gufe/tests/test_smallmoleculecomponent.py b/gufe/tests/test_smallmoleculecomponent.py index 17a1f32c..354771c9 100644 --- a/gufe/tests/test_smallmoleculecomponent.py +++ b/gufe/tests/test_smallmoleculecomponent.py @@ -72,7 +72,6 @@ def test_ensure_ofe_name(internal, rdkit_name, name, expected, recwarn): class TestSmallMoleculeComponent(GufeTokenizableTestsMixin): cls = SmallMoleculeComponent - key = "SmallMoleculeComponent-82d90fcdcbe76a4155b0ea42b9080ff2" repr = "SmallMoleculeComponent(name=ethane)" @pytest.fixture diff --git a/gufe/tests/test_solvents.py b/gufe/tests/test_solvents.py index e63e672c..88b2a87b 100644 --- a/gufe/tests/test_solvents.py +++ b/gufe/tests/test_solvents.py @@ -81,7 +81,6 @@ def test_bad_inputs(pos, neg): class TestSolventComponent(GufeTokenizableTestsMixin): cls = SolventComponent - key = "SolventComponent-26b4034ad9dbd9f908dfc298ea8d449f" repr = "SolventComponent(name=O, Na+, Cl-)" @pytest.fixture diff --git a/gufe/tests/test_tokenization.py b/gufe/tests/test_tokenization.py index e6d035ea..f7b0744d 100644 --- a/gufe/tests/test_tokenization.py +++ b/gufe/tests/test_tokenization.py @@ -83,7 +83,6 @@ class GufeTokenizableTestsMixin(abc.ABC): # set this to the `GufeTokenizable` subclass you are testing cls: type[GufeTokenizable] - key: Optional[str] repr: Optional[str] @pytest.fixture @@ -141,7 +140,14 @@ def test_to_shallow_dict_roundtrip(self, instance): #assert ser == reser def test_key_stable(self, instance): - assert self.key == instance.key + """Check that generating the instance from a dict representation yields + the same key (and the same instance). + + """ + instance_ = GufeTokenizable.from_dict(instance.to_dict()) + + assert instance_.key == instance.key + assert instance_ is instance def test_repr(self, instance): if self.repr is None: @@ -154,7 +160,6 @@ def test_repr(self, instance): class TestGufeTokenizable(GufeTokenizableTestsMixin): cls = Container - key = "Container-3fcec08974fbbd0371fed8a185628b70" repr = "Container(Leaf(Leaf(foo, 2), 2), [Leaf(foo, 2), 0], {'leaf': Leaf(foo, 2), 'a': 'b'})" @pytest.fixture diff --git a/gufe/tests/test_transformation.py b/gufe/tests/test_transformation.py index ea53a582..3ad29c59 100644 --- a/gufe/tests/test_transformation.py +++ b/gufe/tests/test_transformation.py @@ -31,7 +31,6 @@ def complex_equilibrium(solvated_complex): class TestTransformation(GufeTokenizableTestsMixin): cls = Transformation - key = "Transformation-3e001d3eaa6eb0cb1a77f6460f3f6f29" repr = "Transformation(stateA=ChemicalSystem(name=, components={'ligand': SmallMoleculeComponent(name=toluene), 'solvent': SolventComponent(name=O, K+, Cl-)}), stateB=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=)" @pytest.fixture @@ -141,7 +140,6 @@ def test_deprecation_warning_on_dict_mapping(self, solvated_ligand, solvated_com class TestNonTransformation(GufeTokenizableTestsMixin): cls = NonTransformation - key = "NonTransformation-5fe8c396da48515ad75acc7cb5d02607" repr = "NonTransformation(stateA=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), stateB=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=)" @pytest.fixture