How to use pytest_configure method in Splinter

Best Python code snippet using splinter

test_model.py

Source:test_model.py Github

copy

Full Screen

...49 model.fit(X_train, y_train)50 score = model.score(X_test, y_test)51 print(f"{model.__class__.__name__} score: {score}")52 assert score >= 0.7, f"{model.__class__.__name__} failed"53def pytest_configure():54 pytest.base_model = 0.055def test_base_model(dataset):56 X_train, X_test, y_train, y_test = dataset57 model = RandomForestClassifier(n_estimators=100, oob_score=True)58 model.fit(X_train, y_train)59 score = f1_score(y_test, model.predict(X_test))60 assert score > 0.7, f"base model failed"61 pytest_configure.base_model = score62@pytest.mark.skip('No difference found')63def test_random_forest_drop_unimportant_feature(dataset):64 X_train, X_test, y_train, y_test = dataset65 X_train = X_train.drop(columns=['Alone'])66 X_test = X_test.drop(columns=['Alone'])67 model = RandomForestClassifier(n_estimators=100, oob_score=True)...

Full Screen

Full Screen

pytest_collection_loader.py

Source:pytest_collection_loader.py Github

copy

Full Screen

...11 for parent in path.parents:12 if str(parent) == ANSIBLE_COLLECTIONS_PATH:13 return parent14 raise Exception('File "%s" not found in collection path "%s".' % (path, ANSIBLE_COLLECTIONS_PATH))15def pytest_configure():16 """Configure this pytest plugin."""17 try:18 if pytest_configure.executed:19 return20 except AttributeError:21 pytest_configure.executed = True22 # If ANSIBLE_HOME is set make sure we add it to the PYTHONPATH to ensure it is picked up. Not all env vars are23 # picked up by vscode (.bashrc is a notable one) so a user can define it manually in their .env file.24 ansible_home = os.environ.get('ANSIBLE_HOME', None)25 if ansible_home:26 sys.path.insert(0, os.path.join(ansible_home, 'lib'))27 from ansible.utils.collection_loader._collection_finder import _AnsibleCollectionFinder28 # allow unit tests to import code from collections29 # noinspection PyProtectedMember30 _AnsibleCollectionFinder(paths=[os.path.dirname(ANSIBLE_COLLECTIONS_PATH)])._install() # pylint: disable=protected-access31 # noinspection PyProtectedMember32 from _pytest import pathlib as pytest_pathlib33 pytest_pathlib.resolve_package_path = collection_resolve_package_path...

Full Screen

Full Screen

test_initialization.py

Source:test_initialization.py Github

copy

Full Screen

...9 import django.apps10 assert django.apps.apps.ready11 from tpkg.app.models import Item12 print("conftest")13 def pytest_configure():14 import django15 print("pytest_configure: conftest")16 django.setup = lambda: SHOULD_NOT_GET_CALLED17 """18 )19 django_testdir.project_root.join("tpkg", "plugin.py").write(20 dedent(21 """22 import pytest23 import django.apps24 assert not django.apps.apps.ready25 print("plugin")26 def pytest_configure():27 assert django.apps.apps.ready28 from tpkg.app.models import Item29 print("pytest_configure: plugin")30 @pytest.hookimpl(tryfirst=True)31 def pytest_load_initial_conftests(early_config, parser, args):32 print("pytest_load_initial_conftests")33 assert not django.apps.apps.ready34 """35 )36 )37 django_testdir.makepyfile(38 """39 def test_ds():40 pass...

Full Screen

Full Screen

ansible_pytest_coverage.py

Source:ansible_pytest_coverage.py Github

copy

Full Screen

1"""Monkey patch os._exit when running under coverage so we don't lose coverage data in forks, such as with `pytest --boxed`. PYTEST_DONT_REWRITE"""2from __future__ import (absolute_import, division, print_function)3__metaclass__ = type4def pytest_configure():5 """Configure this pytest plugin."""6 try:7 if pytest_configure.executed:8 return9 except AttributeError:10 pytest_configure.executed = True11 try:12 import coverage13 except ImportError:14 coverage = None15 try:16 coverage.Coverage17 except AttributeError:18 coverage = None19 if not coverage:20 return21 import gc22 import os23 coverage_instances = []24 for obj in gc.get_objects():25 if isinstance(obj, coverage.Coverage):26 coverage_instances.append(obj)27 if not coverage_instances:28 coverage_config = os.environ.get('COVERAGE_CONF')29 if not coverage_config:30 return31 coverage_output = os.environ.get('COVERAGE_FILE')32 if not coverage_output:33 return34 cov = coverage.Coverage(config_file=coverage_config)35 coverage_instances.append(cov)36 else:37 cov = None38 # noinspection PyProtectedMember39 os_exit = os._exit # pylint: disable=protected-access40 def coverage_exit(*args, **kwargs):41 for instance in coverage_instances:42 instance.stop()43 instance.save()44 os_exit(*args, **kwargs)45 os._exit = coverage_exit # pylint: disable=protected-access46 if cov:47 cov.start()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Splinter automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful