How to use the pytest.main function in pytest

To help you get started, we’ve selected a few pytest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github numpy / numpy-stubs / runtests.py View on Github external
def run_pytest(argv):
    subprocess.run(
        [sys.executable, "-m", "pip", "install", STUBS_ROOT],
        capture_output=True,
        check=True,
    )
    return pytest.main([STUBS_ROOT] + argv)
github fmfn / BayesianOptimization / tests / test_bayesian_optimization.py View on Github external
assert tracker.end_count == 2

    optimizer.maximize(init_points=0, n_iter=2)
    assert optimizer._queue.empty
    assert len(optimizer.space) == 5
    assert tracker.start_count == 3
    assert tracker.step_count == 5
    assert tracker.end_count == 3


if __name__ == '__main__':
    r"""
    CommandLine:
        python tests/test_bayesian_optimization.py
    """
    pytest.main([__file__])
github sibirrer / lenstronomy / test / test_Util / test_class_creator.py View on Github external
multi_band_type = 'single-band'
        multi_band = class_creator.create_im_sim(multi_band_list, multi_band_type, kwargs_model, bands_compute=None,
                                                  likelihood_mask_list=None, band_index=0)
        assert multi_band.LensModel.lens_model_list[0] == 'SIS'


class TestRaise(unittest.TestCase):

    def test_raise(self):
        with self.assertRaises(ValueError):
            class_creator.create_im_sim(multi_band_list=None, multi_band_type='WRONG', kwargs_model=None,
                                        bands_compute=None, likelihood_mask_list=None, band_index=0)


if __name__ == '__main__':
    pytest.main()
github DLR-RM / RAFCON / tests / gui / test_i18n.py View on Github external
with use_locale("de_DE.UTF-8", monkeypatch):
        gui.restart()

        main_window_controller = gui.singletons.main_window_controller
        gvm_controller = main_window_controller.get_controller('global_variable_manager_ctrl')
        gvm_view = gvm_controller.view
        remove_button = gvm_view["delete_global_variable_button"]

        print("Found text in label is: ", _("Remove"), remove_button.get_label())
        assert _("Remove") == "Entfernen" == remove_button.get_label()


if __name__ == '__main__':
    import pytest
    pytest.main([__file__])
github deanishe / alfred-workflow / tests / test_notify.py View on Github external
assert os.path.exists(APP_PATH) is False
    notify.install_notifier()
    assert os.path.exists(APP_PATH) is True
    icns_path = os.path.join(tempdir, 'icon.icns')
    assert os.path.exists(icns_path) is False
    notify.png_to_icns(PNG_PATH, icns_path)
    assert os.path.exists(icns_path) is True
    with open(icns_path, 'rb') as fp:
        h1 = hashlib.md5(fp.read())
    with open(ICON_PATH, 'rb') as fp:
        h2 = hashlib.md5(fp.read())
    assert h1.digest() == h2.digest()


if __name__ == '__main__':  # pragma: no cover
    pytest.main([__file__])
github yoshida-lab / XenonPy / tests / descriptor / test_structures.py View on Github external
RadialDistributionFunction().fit_transform(data)
    assert True


def test_ofm(data):
    OrbitalFieldMatrix().fit_transform(data)
    assert True


def test_structure(data):
    Structures().fit_transform(data)
    assert True


if __name__ == "__main__":
    pytest.main()
github Kozea / pygal / setup.py View on Github external
def run_tests(self):
        # import here, cause outside the eggs aren't loaded
        import pytest
        errno = pytest.main(self.test_args)
        sys.exit(errno)
github hjacobs / codevalidator / setup.py View on Github external
def run_tests(self):
        try:
            import pytest
        except:
            raise RuntimeError('py.test is not installed, run: pip install pytest')
        params = {'args': self.test_args}
        if self.cov:
            params['args'] += self.cov
            params['plugins'] = ['cov']
        if self.junitxml:
            params['args'] += self.junitxml
        params['args'] += ['--doctest-modules', 'codevalidator.py', '-s', '-vv']
        errno = pytest.main(**params)
        sys.exit(errno)
github BD2KGenomics / s3am / setup.py View on Github external
def run_tests( self ):
        import pytest
        # Sanitize command line arguments to avoid confusing Toil code attempting to parse them
        sys.argv[ 1: ] = [ ]
        errno = pytest.main( self.pytest_args )
        sys.exit( errno )
github ConsenSys / py-eip712-structs / setup.py View on Github external
def run_tests(self):
        # import here, cause outside the eggs aren't loaded
        import pytest

        errno = pytest.main(shlex.split(self.pytest_args))
        sys.exit(errno)