Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on pytest-subtests. #379

Merged
merged 5 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Removed
+++++++

- Dropped support for Python 3.5 (#340). The signac project will follow the `NEP 29 deprecation policy <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_ going forward.
- Removed dependency on ``pytest-subtests`` (#379).


[1.4.0] -- 2020-02-28
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'
137 changes: 63 additions & 74 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down