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

nose missing some tests #4431

Closed
rcomer opened this issue Nov 22, 2021 · 1 comment · Fixed by #4450
Closed

nose missing some tests #4431

rcomer opened this issue Nov 22, 2021 · 1 comment · Fixed by #4450
Assignees

Comments

@rcomer
Copy link
Member

rcomer commented Nov 22, 2021

📰 Custom Issue

We have some tests for NetCDF loading that are created by using setattr on the test class:

# Add in tests methods to exercise each (supported) vertical coordinate type
# individually.
# NOTE: hh.CF_COORD_VERTICAL lists all the valid types, but we don't yet
# support all of them.
_SUPPORTED_FORMULA_TYPES = (
# NOTE: omit "atmosphere_hybrid_height_coordinate" : our basic testcase
"atmosphere_sigma_coordinate",
"atmosphere_hybrid_sigma_pressure_coordinate",
"ocean_sigma_z_coordinate",
"ocean_sigma_coordinate",
"ocean_s_coordinate",
"ocean_s_coordinate_g1",
"ocean_s_coordinate_g2",
)
for hybrid_type in _SUPPORTED_FORMULA_TYPES:
def construct_inner_func(hybrid_type):
term_names = hh.CF_COORD_VERTICAL[hybrid_type]
def inner(self):
result = self.run_testcase(
formula_root_name=hybrid_type, term_names=term_names
)
self.check_result(
result, factory_type=hybrid_type, formula_terms=term_names
)
return inner
# Note: use an intermediate function to generate each test method, simply to
# generate a new local variable for 'hybrid_type' on each iteration.
# Otherwise all the test methods will refer to the *same* 'hybrid_type'
# variable, i.e. the loop variable, which does not work !
method_name = f"test_{hybrid_type}_coord"
setattr(
Test__formulae_tests, method_name, construct_inner_func(hybrid_type)
)

nose does not seem to be discovering these. They run fine if you run the module directly, and they are also discovered by pytest. So this issue would be solved by implementing #3835 🙂

@wjbenfold
Copy link
Contributor

Decision from peloton is to fix this here by building the tests in such a way as nose discovers them.

We're keen to move to pytest soon, but not soon enough that this shouldn't be fixed to run on nose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants