diff --git a/changelog.txt b/changelog.txt index 91d82ffbb..3eb0e6f9d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -34,6 +34,7 @@ Removed +++++++ - Dropped support for Python 3.5 (#340). The signac project will follow the `NEP 29 deprecation policy `_ going forward. + - Removed dependency on ``pytest-subtests`` (#379). [1.4.0] -- 2020-02-28 diff --git a/requirements-dev.txt b/requirements-dev.txt index fcc2678a5..edf873c42 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,7 +5,6 @@ numpy==1.19.1 pandas==1.1.1; implementation_name=='cpython' pymongo==3.11.0; implementation_name=='cpython' pytest-cov==2.10.1 -pytest-subtests==0.3.2 pytest==6.0.1 ruamel.yaml==0.16.10 tables==3.6.1; implementation_name=='cpython' diff --git a/tests/test_project.py b/tests/test_project.py index fba2f0c9e..c620daa5f 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1480,85 +1480,72 @@ def test_import_own_project(self): assert len(tmp_project) == len(self.project) -class TestProjectRepresentation(TestProjectBase): +VALID_SP_VALUES = [None, 0, 1, 0.0, 1.0, True, False, [0, 1, 2], [0, 1.0, False]] + + +def add_jobs_homogeneous(project, num_jobs): + # Add jobs with many different state points + for i in range(num_jobs): + project.open_job( + {'{}_{}'.format(i, j): v + for j, v in enumerate(VALID_SP_VALUES)}).init() + + +def add_jobs_heterogeneous(project, num_jobs): + # Add jobs with many different state points + for i in range(num_jobs): + for v in VALID_SP_VALUES: + project.open_job(dict(a=v)).init() + - valid_sp_values = [None, 0, 1, 0.0, 1.0, True, False, [0, 1, 2], [0, 1.0, False]] +project_repr_generators = [ + (add_jobs_homogeneous, 0), + (add_jobs_homogeneous, 10), + (add_jobs_homogeneous, 200), + (add_jobs_heterogeneous, 0), + (add_jobs_heterogeneous, 10), + (add_jobs_heterogeneous, 200)] + + +class TestProjectRepresentation(TestProjectBase): num_few_jobs = 10 num_many_jobs = 200 - def call_repr_methods(self, subtests): - - with subtests.test(of='project'): - with subtests.test(type='str'): - str(self.project) - with subtests.test(type='repr'): - assert eval(repr(self.project)) == self.project - with subtests.test(type='html'): - for use_pandas in (True, False): - type(self.project)._use_pandas_for_html_repr = use_pandas - with subtests.test(use_pandas=use_pandas): - if use_pandas and not PANDAS: - raise pytest.skip('requires use_pandas') - self.project._repr_html_() - - with subtests.test(of='JobsCursor'): - for filter_ in (None, ): - with subtests.test(filter=filter_): - with subtests.test(type='str'): - str(self.project.find_jobs(filter_)) - with subtests.test(type='repr'): - q = self.project.find_jobs(filter_) - assert eval(repr(q)) == q - with subtests.test(type='html'): - for use_pandas in (True, False): - type(self.project)._use_pandas_for_html_repr = use_pandas - with subtests.test(use_pandas=use_pandas): - if use_pandas and not PANDAS: - raise pytest.skip('requires use_pandas') - self.project.find_jobs(filter_)._repr_html_() - - with subtests.test(of='Schema'): - schema = self.project.detect_schema() - with subtests.test(type='str'): - str(schema) - with subtests.test(type='repr'): - repr(schema) - with subtests.test(type='html'): - schema._repr_html_() - - def test_repr_no_jobs(self, subtests): - self.call_repr_methods(subtests) - - def test_repr_few_jobs_homogeneous(self, subtests): - # Many jobs with many different state points - for i in range(self.num_few_jobs): - self.project.open_job( - {'{}_{}'.format(i, j): v - for j, v in enumerate(self.valid_sp_values)}).init() - self.call_repr_methods(subtests) - - def test_repr_many_jobs_homogeneous(self, subtests): - # Many jobs with many different state points - for i in range(self.num_many_jobs): - self.project.open_job( - {'{}_{}'.format(i, j): v - for j, v in enumerate(self.valid_sp_values)}).init() - self.call_repr_methods(subtests) - - def test_repr_few_jobs_heterogeneous(self, subtests): - # Many jobs with many different state points - for i in range(self.num_few_jobs): - for v in self.valid_sp_values: - self.project.open_job(dict(a=v)).init() - self.call_repr_methods(subtests) - - def test_repr_many_jobs_heterogeneous(self, subtests): - # Many jobs with many different state points - for i in range(self.num_many_jobs): - for v in self.valid_sp_values: - self.project.open_job(dict(a=v)).init() - self.call_repr_methods(subtests) + @pytest.mark.parametrize("project_generator,num_jobs", project_repr_generators) + def test_project_repr_methods(self, project_generator, num_jobs): + project_generator(self.project, num_jobs) + assert len(str(self.project)) > 0 + assert 'project' in str(self.project) + assert len(repr(self.project)) > 0 + assert eval(repr(self.project)) == self.project + for use_pandas in (True, False): + type(self.project)._use_pandas_for_html_repr = use_pandas + if use_pandas and not PANDAS: + raise pytest.skip('requires use_pandas') + self.project._repr_html_() + + @pytest.mark.parametrize("project_generator,num_jobs", project_repr_generators) + def test_JobsCursor_repr_methods(self, project_generator, num_jobs): + project_generator(self.project, num_jobs) + for filter_ in (None, ): + assert len(str(self.project.find_jobs(filter_))) > 0 + assert len(repr(self.project.find_jobs(filter_))) > 0 + q = self.project.find_jobs(filter_) + assert eval(repr(q)) == q + for use_pandas in (True, False): + type(self.project)._use_pandas_for_html_repr = use_pandas + if use_pandas and not PANDAS: + raise pytest.skip('requires use_pandas') + self.project.find_jobs(filter_)._repr_html_() + + @pytest.mark.parametrize("project_generator,num_jobs", project_repr_generators) + def test_Schema_repr_methods(self, project_generator, num_jobs): + project_generator(self.project, num_jobs) + schema = self.project.detect_schema() + assert len(str(schema)) > 0 + assert len(repr(schema)) > 0 + schema._repr_html_() class TestLinkedViewProject(TestProjectBase): @@ -2280,6 +2267,7 @@ class TestProjectStore(TestProjectStoreBase, test_h5store.TestH5Store): the project data interface opens one instance of H5Store. This test will (and should) fail using the project data interface. """ + def test_assign_valid_types_within_same_file(self): pass @@ -2291,6 +2279,7 @@ class TestProjectStoreOpen(TestProjectStoreBase, test_h5store.TestH5StoreOpen): the project data interface opens one instance of H5Store. This test will (and should) fail using the project data interface. """ + def test_open_write_and_read_only(self): pass