8000 Structure of tests and parameterization of fixtures · Issue #59 · leap-c/leap-c · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 8000
Structure of tests and parameterization of fixtures #59
Open
@JasperHoffmann

Description

@JasperHoffmann

Hi everyone,

currently the parameterization of tests could be improved. For example the fixture all_tasks returns a list. However, pytest allows to paramterize fixtures, such that we can pass single envs and omit the for loops in the tests:

def test_env_reset(all_env: list[gym.Env]):
    """Test the reset functionality of our environments.

    This test function verifies that the reset method of the environments produces
    consistent initial states when called with the same seed.

    Args:
        all_env (list[gym.Env]): List of environment instances to test.

    The test:
    1. Calls reset twice with same seed (0)
    2. Verifies state is not None
    3. Asserts both calls return same initial state vectors
    """
    for env in all_env:
        x, _ = env.reset(seed=0)
        assert x is not None
        x_, _ = env.reset(seed=0)

        assert np.allclose(x, x_)

Furthermore, currently the tests are not really structured accordingly to the project structure... Thus, my suggestion would be a restructuring of the tests!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0