Closed nleroy917 closed 2 years ago
Is there a good, reliable way of comparing two instantiated Project()
classes for checking if they are identical?
Is there a good, reliable way of comparing two instantiated
Project()
classes for checking if they are identical?
1) Try to get all the object variables from two projects and compare them? 2) Try to call some functions from that Project?
@Khoroshevskyi Let me know what you think of the new from_dict()
method I wrote. I added some tests too. As of right now, I am just comparing the dictionary representations of the projects to confirm they are accurate:
@pytest.mark.parametrize(
"example_pep_cfg_path", EXAMPLE_TYPES, indirect=True
)
def test_from_dict_instatiation(self, example_pep_cfg_path):
"""
Verify that we can accurately instantiate a project from
its dictionary representation.
"""
p = Project(cfg=example_pep_cfg_path)
p2 = Project() # empty
p2.from_dict(p.to_dict())
assert p.to_dict() == p2.to_dict()
Doesn't feel bulletproof, though.
Fixed
Right now,
peppy
's API only lets you create aProject()
from a file that is on disk. It would be nice to have the option to create an instance ofProject()
from a PEP that is already in memory (say, a Pythondict
).Right now the
__init__
function looks for astr
to load the configuration file usingparse_config_file
. It could be nice to have another case where it looks for adict
and parses the configuration that way. Maybe something likeparse_config_dict
which is identical toparse_config_file
, but simply starts with an already loadeddict
:Discussed with @Khoroshevskyi