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

Add tests where appropriate #20

Open
RobertRosca opened this issue Mar 24, 2021 · 0 comments
Open

Add tests where appropriate #20

RobertRosca opened this issue Mar 24, 2021 · 0 comments

Comments

@RobertRosca
Copy link
Collaborator

Python packages with test methods should have tests added to them.

First thing to include is the install time test callbacks:

class ...
    install_time_test_callbacks = ['import_module_test']
    ...

Also, where package has pytest tests set up, you can use the following to overwrite the default PythonPackage test behaviour to execute pytests:

class ...
    def test(self):
        # `setup.py test` should not be used as:
        #   - `python3 -m pytest -v` should be ran instead
        #   - the builtin `test` method runs before `install` is finished
        self.pytest()

    def pytest(self):
        with working_dir('.'):
            prefix = self.spec.prefix
            #  Add bin to path here, as tests also check entrypoints
            env['PATH'] = env['PATH']+":"+prefix+"/bin"
            python('-m', 'pytest', '-v')
    ...

Where the prefix... and env lines are only required when testing packages that implement entrypoints.

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

No branches or pull requests

1 participant