Hello community,
here is the log from the commit of package python-pytest-randomly for
openSUSE:Factory checked in at 2019-09-10 00:03:14
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-randomly (Old)
and /work/SRC/openSUSE:Factory/.python-pytest-randomly.new.7948 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-randomly"
Tue Sep 10 00:03:14 2019 rev:5 rq:729484 version:3.1.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-pytest-randomly/python-pytest-randomly.changes
2019-06-03 18:57:09.756388968 +0200
+++
/work/SRC/openSUSE:Factory/.python-pytest-randomly.new.7948/python-pytest-randomly.changes
2019-09-10 00:03:18.465208207 +0200
@@ -1,0 +2,9 @@
+Mon Sep 9 09:20:12 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 3.1.0:
+ * Add plugins via entry points pytest_randomly.random_seeder to allow
+ outside packages to register additional random generators to seed.
+ This has added a dependency on the entrypoints package.
+- Drop patch tests-restore-python2.7.patch
+
+-------------------------------------------------------------------
Old:
----
pytest-randomly-3.0.0.tar.gz
tests-restore-python2.7.patch
New:
----
pytest-randomly-3.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pytest-randomly.spec ++++++
--- /var/tmp/diff_new_pack.pyyeyX/_old 2019-09-10 00:03:19.773208119 +0200
+++ /var/tmp/diff_new_pack.pyyeyX/_new 2019-09-10 00:03:19.777208119 +0200
@@ -16,26 +16,27 @@
#
+%define skip_python2 1
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pytest-randomly
-Version: 3.0.0
+Version: 3.1.0
Release: 0
Summary: Pytest plugin to randomly order tests and control random.seed
License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/adamchainz/pytest-randomly
Source:
https://files.pythonhosted.org/packages/source/p/pytest-randomly/pytest-randomly-%{version}.tar.gz
-# Reverse of https://github.com/pytest-dev/pytest-randomly/commit/7ca48ad.patch
-Patch0: tests-restore-python2.7.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
+Requires: python-entrypoints
Requires: python-pytest
Recommends: python-Faker
Suggests: python-numpy
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module Faker}
+BuildRequires: %{python_module entrypoints}
BuildRequires: %{python_module factory_boy}
BuildRequires: %{python_module numpy}
BuildRequires: %{python_module pytest}
@@ -65,7 +66,6 @@
%prep
%setup -q -n pytest-randomly-%{version}
-%patch0 -p1
# Disregard Python 3.4+ restriction
sed -i '/python_requires/d' setup.py
@@ -78,7 +78,8 @@
%check
export PYTHONDONTWRITEBYTECODE=true
-%pytest
+# test_entrypoint_injection needs installed module for pytest to use
+%pytest -k 'not test_entrypoint_injection'
%files %{python_files}
%doc AUTHORS.rst README.rst
++++++ pytest-randomly-3.0.0.tar.gz -> pytest-randomly-3.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-randomly-3.0.0/HISTORY.rst
new/pytest-randomly-3.1.0/HISTORY.rst
--- old/pytest-randomly-3.0.0/HISTORY.rst 2019-04-05 11:31:58.000000000
+0200
+++ new/pytest-randomly-3.1.0/HISTORY.rst 2019-08-25 13:54:27.000000000
+0200
@@ -8,6 +8,13 @@
.. Insert new release notes below this line
+3.1.0 (2019-08-25)
+------------------
+
+* Add plugins via entry points ``pytest_randomly.random_seeder`` to allow
+ outside packages to register additional random generators to seed. This has
+ added a dependency on the ``entrypoints`` package.
+
3.0.0 (2019-04-05)
------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-randomly-3.0.0/PKG-INFO
new/pytest-randomly-3.1.0/PKG-INFO
--- old/pytest-randomly-3.0.0/PKG-INFO 2019-04-05 11:32:22.000000000 +0200
+++ new/pytest-randomly-3.1.0/PKG-INFO 2019-08-25 13:54:38.000000000 +0200
@@ -1,11 +1,12 @@
Metadata-Version: 1.2
Name: pytest-randomly
-Version: 3.0.0
+Version: 3.1.0
Summary: Pytest plugin to randomly order tests and control random.seed.
Home-page: https://github.com/pytest-dev/pytest-randomly
Author: Adam Johnson
Author-email: [email protected]
License: BSD
+Project-URL: Changelog,
https://github.com/pytest-dev/pytest-randomly/blob/master/HISTORY.rst
Description: ===============
pytest-randomly
===============
@@ -16,6 +17,9 @@
.. image:: https://img.shields.io/pypi/v/pytest-randomly.svg
:target: https://pypi.python.org/pypi/pytest-randomly
+ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
+ :target: https://github.com/python/black
+
.. figure::
https://raw.githubusercontent.com/pytest-dev/pytest-randomly/master/logo.png
:scale: 50%
:alt: Randomness power.
@@ -44,6 +48,11 @@
data in tests - factory boy uses faker for lots of data.
* If `numpy <http://www.numpy.org/>`_ is installed, its random state
is reset
at the start of every test.
+ * If additional random generators are used, they can be registered
under the
+ ``pytest_randomly.random_seeder``
+ `entry point
<https://packaging.python.org/specifications/entry-points/>`_ and
+ will have their seed reset at the start of every test. Register a
function
+ that takes the current seed value.
About
-----
@@ -133,6 +142,13 @@
.. Insert new release notes below this line
+ 3.1.0 (2019-08-25)
+ ------------------
+
+ * Add plugins via entry points ``pytest_randomly.random_seeder`` to
allow
+ outside packages to register additional random generators to seed.
This has
+ added a dependency on the ``entrypoints`` package.
+
3.0.0 (2019-04-05)
------------------
@@ -210,6 +226,7 @@
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
+Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-randomly-3.0.0/README.rst
new/pytest-randomly-3.1.0/README.rst
--- old/pytest-randomly-3.0.0/README.rst 2019-03-26 21:10:58.000000000
+0100
+++ new/pytest-randomly-3.1.0/README.rst 2019-08-25 13:54:07.000000000
+0200
@@ -8,6 +8,9 @@
.. image:: https://img.shields.io/pypi/v/pytest-randomly.svg
:target: https://pypi.python.org/pypi/pytest-randomly
+.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
+ :target: https://github.com/python/black
+
.. figure::
https://raw.githubusercontent.com/pytest-dev/pytest-randomly/master/logo.png
:scale: 50%
:alt: Randomness power.
@@ -36,6 +39,11 @@
data in tests - factory boy uses faker for lots of data.
* If `numpy <http://www.numpy.org/>`_ is installed, its random state is reset
at the start of every test.
+* If additional random generators are used, they can be registered under the
+ ``pytest_randomly.random_seeder``
+ `entry point <https://packaging.python.org/specifications/entry-points/>`_
and
+ will have their seed reset at the start of every test. Register a function
+ that takes the current seed value.
About
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-randomly-3.0.0/pytest_randomly.egg-info/PKG-INFO
new/pytest-randomly-3.1.0/pytest_randomly.egg-info/PKG-INFO
--- old/pytest-randomly-3.0.0/pytest_randomly.egg-info/PKG-INFO 2019-04-05
11:32:21.000000000 +0200
+++ new/pytest-randomly-3.1.0/pytest_randomly.egg-info/PKG-INFO 2019-08-25
13:54:38.000000000 +0200
@@ -1,11 +1,12 @@
Metadata-Version: 1.2
Name: pytest-randomly
-Version: 3.0.0
+Version: 3.1.0
Summary: Pytest plugin to randomly order tests and control random.seed.
Home-page: https://github.com/pytest-dev/pytest-randomly
Author: Adam Johnson
Author-email: [email protected]
License: BSD
+Project-URL: Changelog,
https://github.com/pytest-dev/pytest-randomly/blob/master/HISTORY.rst
Description: ===============
pytest-randomly
===============
@@ -16,6 +17,9 @@
.. image:: https://img.shields.io/pypi/v/pytest-randomly.svg
:target: https://pypi.python.org/pypi/pytest-randomly
+ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
+ :target: https://github.com/python/black
+
.. figure::
https://raw.githubusercontent.com/pytest-dev/pytest-randomly/master/logo.png
:scale: 50%
:alt: Randomness power.
@@ -44,6 +48,11 @@
data in tests - factory boy uses faker for lots of data.
* If `numpy <http://www.numpy.org/>`_ is installed, its random state
is reset
at the start of every test.
+ * If additional random generators are used, they can be registered
under the
+ ``pytest_randomly.random_seeder``
+ `entry point
<https://packaging.python.org/specifications/entry-points/>`_ and
+ will have their seed reset at the start of every test. Register a
function
+ that takes the current seed value.
About
-----
@@ -133,6 +142,13 @@
.. Insert new release notes below this line
+ 3.1.0 (2019-08-25)
+ ------------------
+
+ * Add plugins via entry points ``pytest_randomly.random_seeder`` to
allow
+ outside packages to register additional random generators to seed.
This has
+ added a dependency on the ``entrypoints`` package.
+
3.0.0 (2019-04-05)
------------------
@@ -210,6 +226,7 @@
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
+Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-randomly-3.0.0/pytest_randomly.egg-info/requires.txt
new/pytest-randomly-3.1.0/pytest_randomly.egg-info/requires.txt
--- old/pytest-randomly-3.0.0/pytest_randomly.egg-info/requires.txt
2019-04-05 11:32:21.000000000 +0200
+++ new/pytest-randomly-3.1.0/pytest_randomly.egg-info/requires.txt
2019-08-25 13:54:38.000000000 +0200
@@ -1 +1,2 @@
+entrypoints
pytest
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-randomly-3.0.0/pytest_randomly.py
new/pytest-randomly-3.1.0/pytest_randomly.py
--- old/pytest-randomly-3.0.0/pytest_randomly.py 2019-04-05
11:31:55.000000000 +0200
+++ new/pytest-randomly-3.1.0/pytest_randomly.py 2019-08-25
13:54:16.000000000 +0200
@@ -2,16 +2,19 @@
import random
import time
+import entrypoints
from pytest import Collector
# factory-boy
try:
from factory.random import set_random_state as factory_set_random_state
+
have_factory_boy = True
except ImportError:
# old versions
try:
from factory.fuzzy import set_random_state as factory_set_random_state
+
have_factory_boy = True
except ImportError:
have_factory_boy = False
@@ -19,6 +22,7 @@
# faker
try:
from faker.generator import random as faker_random
+
have_faker = True
except ImportError:
have_faker = False
@@ -26,19 +30,20 @@
# numpy
try:
from numpy import random as np_random
+
have_numpy = True
except ImportError:
have_numpy = False
-__version__ = '3.0.0'
+__version__ = "3.1.0"
default_seed = int(time.time())
def seed_type(string):
- if string == 'last':
+ if string == "last":
return string
try:
return int(string)
@@ -49,26 +54,33 @@
def pytest_addoption(parser):
- group = parser.getgroup('randomly', 'Randomizes tests')
+ group = parser.getgroup("randomly", "Randomizes tests")
group._addoption(
- '--randomly-seed', action='store', dest='randomly_seed',
- default=str(default_seed), type=seed_type,
+ "--randomly-seed",
+ action="store",
+ dest="randomly_seed",
+ default=str(default_seed),
+ type=seed_type,
help="""Set the seed that pytest-randomly uses (int), or pass the
special value 'last' to reuse the seed from the previous run.
Default behaviour: use int(time.time()), so the seed is
- different on each run."""
+ different on each run.""",
)
group._addoption(
- '--randomly-dont-reset-seed', action='store_false',
- dest='randomly_reset_seed', default=True,
+ "--randomly-dont-reset-seed",
+ action="store_false",
+ dest="randomly_reset_seed",
+ default=True,
help="""Stop pytest-randomly from resetting random.seed() at the
start of every test context (e.g. TestCase) and individual
- test."""
+ test.""",
)
group._addoption(
- '--randomly-dont-reorganize', action='store_false',
- dest='randomly_reorganize', default=True,
- help="Stop pytest-randomly from randomly reorganizing the test order."
+ "--randomly-dont-reorganize",
+ action="store_false",
+ dest="randomly_reorganize",
+ default=True,
+ help="Stop pytest-randomly from randomly reorganizing the test order.",
)
@@ -76,8 +88,12 @@
np_random_states = {}
+entrypoint_reseeds = None
+
+
def _reseed(config, offset=0):
- seed = config.getoption('randomly_seed') + offset
+ global entrypoint_reseeds
+ seed = config.getoption("randomly_seed") + offset
if seed not in random_states:
random.seed(seed)
random_states[seed] = random.getstate()
@@ -97,36 +113,43 @@
else:
np_random.set_state(np_random_states[seed])
+ if entrypoint_reseeds is None:
+ entrypoint_reseeds = [
+ e.load() for e in
entrypoints.get_group_all("pytest_randomly.random_seeder")
+ ]
+ for reseed in entrypoint_reseeds:
+ reseed(seed)
+
def pytest_report_header(config):
- seed_value = config.getoption('randomly_seed')
- if seed_value == 'last':
- seed = config.cache.get('randomly_seed', default_seed)
+ seed_value = config.getoption("randomly_seed")
+ if seed_value == "last":
+ seed = config.cache.get("randomly_seed", default_seed)
else:
seed = seed_value
- config.cache.set('randomly_seed', seed)
+ config.cache.set("randomly_seed", seed)
config.option.randomly_seed = seed
_reseed(config)
return "Using --randomly-seed={0}".format(seed)
def pytest_runtest_setup(item):
- if item.config.getoption('randomly_reset_seed'):
+ if item.config.getoption("randomly_reset_seed"):
_reseed(item.config, -1)
def pytest_runtest_call(item):
- if item.config.getoption('randomly_reset_seed'):
+ if item.config.getoption("randomly_reset_seed"):
_reseed(item.config)
def pytest_runtest_teardown(item):
- if item.config.getoption('randomly_reset_seed'):
+ if item.config.getoption("randomly_reset_seed"):
_reseed(item.config, 1)
def pytest_collection_modifyitems(session, config, items):
- if not config.getoption('randomly_reorganize'):
+ if not config.getoption("randomly_reorganize"):
return
_reseed(config)
@@ -138,7 +161,7 @@
for item in items:
try:
- item_module = getattr(item, 'module', None)
+ item_module = getattr(item, "module", None)
except (ImportError, Collector.CollectError):
item_module = None
@@ -165,9 +188,9 @@
for item in items:
if current_cls is None:
- current_cls = getattr(item, 'cls', None)
+ current_cls = getattr(item, "cls", None)
- if getattr(item, 'cls', None) != current_cls:
+ if getattr(item, "cls", None) != current_cls:
random.shuffle(current_items)
class_items.append(current_items)
current_items = [item]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-randomly-3.0.0/setup.cfg
new/pytest-randomly-3.1.0/setup.cfg
--- old/pytest-randomly-3.0.0/setup.cfg 2019-04-05 11:32:22.000000000 +0200
+++ new/pytest-randomly-3.1.0/setup.cfg 2019-08-25 13:54:38.000000000 +0200
@@ -1,9 +1,14 @@
[flake8]
-max-line-length = 120
+max-line-length = 80
+select = C,E,F,W,B,B950
+ignore = E203,E501,W503
[isort]
-multi_line_output = 5
-not_skip = __init__.py
+include_trailing_comma = True
+force_grid_wrap = 0
+line_length = 88
+multi_line_output = 3
+use_parentheses = True
[metadata]
license_file = LICENSE
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-randomly-3.0.0/setup.py
new/pytest-randomly-3.1.0/setup.py
--- old/pytest-randomly-3.0.0/setup.py 2019-03-26 21:10:58.000000000 +0100
+++ new/pytest-randomly-3.1.0/setup.py 2019-08-25 13:54:07.000000000 +0200
@@ -4,50 +4,51 @@
def get_version(filename):
- with open(filename, 'r') as fp:
+ with open(filename, "r") as fp:
contents = fp.read()
return re.search(r"__version__ = ['\"]([^'\"]+)['\"]", contents).group(1)
-version = get_version('pytest_randomly.py')
+version = get_version("pytest_randomly.py")
-with open('README.rst', 'r') as readme_file:
+with open("README.rst", "r") as readme_file:
readme = readme_file.read()
-with open('HISTORY.rst', 'r') as history_file:
- history = history_file.read().replace('.. :changelog:', '')
+with open("HISTORY.rst", "r") as history_file:
+ history = history_file.read().replace(".. :changelog:", "")
setup(
- name='pytest-randomly',
+ name="pytest-randomly",
version=version,
- description="Pytest plugin to randomly order tests and control "
- "random.seed.",
- long_description=readme + '\n\n' + history,
+ description="Pytest plugin to randomly order tests and control "
"random.seed.",
+ long_description=readme + "\n\n" + history,
author="Adam Johnson",
- author_email='[email protected]',
- url='https://github.com/pytest-dev/pytest-randomly',
- py_modules=['pytest_randomly'],
+ author_email="[email protected]",
+ url="https://github.com/pytest-dev/pytest-randomly",
+ project_urls={
+ "Changelog": (
+
"https://github.com/pytest-dev/pytest-randomly/blob/master/HISTORY.rst"
+ )
+ },
+ py_modules=["pytest_randomly"],
include_package_data=True,
- install_requires=[
- 'pytest',
- ],
- python_requires='>=3.5',
+ install_requires=["entrypoints", "pytest"],
+ python_requires=">=3.5",
license="BSD",
zip_safe=False,
- keywords='pytest, random, randomize, randomise, randomly',
- entry_points={
- 'pytest11': ['randomly = pytest_randomly'],
- },
+ keywords="pytest, random, randomize, randomise, randomly",
+ entry_points={"pytest11": ["randomly = pytest_randomly"]},
classifiers=[
- 'Development Status :: 5 - Production/Stable',
- 'Framework :: Pytest',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: BSD License',
- 'Natural Language :: English',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6',
- 'Programming Language :: Python :: 3.7',
+ "Development Status :: 5 - Production/Stable",
+ "Framework :: Pytest",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: BSD License",
+ "Natural Language :: English",
+ "Programming Language :: Python :: 3 :: Only",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.5",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
],
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-randomly-3.0.0/test_pytest_randomly.py
new/pytest-randomly-3.1.0/test_pytest_randomly.py
--- old/pytest-randomly-3.0.0/test_pytest_randomly.py 2019-04-05
11:28:59.000000000 +0200
+++ new/pytest-randomly-3.1.0/test_pytest_randomly.py 2019-08-25
13:54:07.000000000 +0200
@@ -1,13 +1,22 @@
+from unittest.mock import Mock
+
import pytest
-pytest_plugins = ['pytester']
+import pytest_randomly
+
+pytest_plugins = ["pytester"]
+
+
[email protected](autouse=True)
+def reset_entrypoints_cache():
+ yield
+ pytest_randomly.entrypoint_reseeds = None
@pytest.fixture
def ourtestdir(testdir):
- testdir.tmpdir.join('pytest.ini').write(
- '[pytest]\n'
- 'console_output_style = classic'
+ testdir.tmpdir.join("pytest.ini").write(
+ "[pytest]\n" "console_output_style = classic"
)
# Change from default running pytest in-process to running in a subprocess
@@ -33,17 +42,13 @@
def test_it_reports_a_header_when_not_set(simpletestdir):
out = simpletestdir.runpytest()
- assert len([
- x for x in out.outlines if x.startswith('Using --randomly-seed=')
- ]) == 1
+ assert len([x for x in out.outlines if x.startswith("Using
--randomly-seed=")]) == 1
def test_it_reports_a_header_when_set(simpletestdir):
- out = simpletestdir.runpytest('--randomly-seed=10')
- lines = [x for x in out.outlines if x.startswith('Using --randomly-seed=')]
- assert lines == [
- 'Using --randomly-seed=10'
- ]
+ out = simpletestdir.runpytest("--randomly-seed=10")
+ lines = [x for x in out.outlines if x.startswith("Using --randomly-seed=")]
+ assert lines == ["Using --randomly-seed=10"]
def test_it_reuses_the_same_random_seed_per_test(ourtestdir):
@@ -66,7 +71,7 @@
assert test_b.num == test_a.num
"""
)
- out = ourtestdir.runpytest('--randomly-dont-reorganize')
+ out = ourtestdir.runpytest("--randomly-dont-reorganize")
out.assert_outcomes(passed=2, failed=0)
@@ -79,9 +84,11 @@
)
out = ourtestdir.runpytest()
out.assert_outcomes(passed=1, failed=0)
- seed_line = [x for x in out.stdout.lines if x.startswith('Using
--randomly-seed=')][0]
+ seed_line = [x for x in out.stdout.lines if x.startswith("Using
--randomly-seed=")][
+ 0
+ ]
- out = ourtestdir.runpytest('--randomly-seed=last')
+ out = ourtestdir.runpytest("--randomly-seed=last")
out.assert_outcomes(passed=1, failed=0)
out.stdout.fnmatch_lines([seed_line])
@@ -93,13 +100,13 @@
pass
"""
)
- out = ourtestdir.runpytest('--randomly-seed=33')
+ out = ourtestdir.runpytest("--randomly-seed=33")
out.assert_outcomes(passed=1, failed=0)
- out.stdout.fnmatch_lines(['Using --randomly-seed=33'])
+ out.stdout.fnmatch_lines(["Using --randomly-seed=33"])
- out = ourtestdir.runpytest('--randomly-seed=last')
+ out = ourtestdir.runpytest("--randomly-seed=last")
out.assert_outcomes(passed=1, failed=0)
- out.stdout.fnmatch_lines(['Using --randomly-seed=33'])
+ out.stdout.fnmatch_lines(["Using --randomly-seed=33"])
def test_passing_nonsense_for_randomly_seed(ourtestdir):
@@ -109,11 +116,16 @@
pass
"""
)
- out = ourtestdir.runpytest('--randomly-seed=invalidvalue')
+ out = ourtestdir.runpytest("--randomly-seed=invalidvalue")
assert out.ret != 0
- out.stderr.fnmatch_lines([
- "pytest.py: error: argument --randomly-seed: 'invalidvalue' is not an
integer or the string 'last'"
- ])
+ out.stderr.fnmatch_lines(
+ [
+ (
+ "pytest.py: error: argument --randomly-seed: 'invalidvalue' "
+ + "is not an integer or the string 'last'"
+ )
+ ]
+ )
def test_it_resets_the_random_seed_at_the_start_of_test_classes(ourtestdir):
@@ -205,7 +217,7 @@
"""
)
out = ourtestdir.runpytest(
- '--randomly-dont-reset-seed', '--randomly-dont-reorganize',
+ "--randomly-dont-reset-seed", "--randomly-dont-reorganize"
)
out.assert_outcomes(passed=2, failed=0)
@@ -215,22 +227,17 @@
def test_it():
pass
"""
- ourtestdir.makepyfile(
- test_a=code,
- test_b=code,
- test_c=code,
- test_d=code,
- )
- args = ['-v', '--randomly-seed=15']
+ ourtestdir.makepyfile(test_a=code, test_b=code, test_c=code, test_d=code)
+ args = ["-v", "--randomly-seed=15"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=4, failed=0)
assert out.outlines[8:12] == [
- 'test_d.py::test_it PASSED',
- 'test_c.py::test_it PASSED',
- 'test_a.py::test_it PASSED',
- 'test_b.py::test_it PASSED',
+ "test_d.py::test_it PASSED",
+ "test_c.py::test_it PASSED",
+ "test_a.py::test_it PASSED",
+ "test_b.py::test_it PASSED",
]
@@ -239,23 +246,18 @@
def test_it():
pass
"""
- ourtestdir.makepyfile(
- test_a=code,
- test_b=code,
- test_c=code,
- test_d=code,
- )
- args = ['-v', '--randomly-seed=15']
+ ourtestdir.makepyfile(test_a=code, test_b=code, test_c=code, test_d=code)
+ args = ["-v", "--randomly-seed=15"]
- args.append('--randomly-dont-reset-seed')
+ args.append("--randomly-dont-reset-seed")
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=4, failed=0)
assert out.outlines[8:12] == [
- 'test_d.py::test_it PASSED',
- 'test_c.py::test_it PASSED',
- 'test_a.py::test_it PASSED',
- 'test_b.py::test_it PASSED',
+ "test_d.py::test_it PASSED",
+ "test_c.py::test_it PASSED",
+ "test_a.py::test_it PASSED",
+ "test_b.py::test_it PASSED",
]
@@ -285,16 +287,16 @@
pass
"""
)
- args = ['-v', '--randomly-seed=15']
+ args = ["-v", "--randomly-seed=15"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=4, failed=0)
assert out.outlines[8:12] == [
- 'test_one.py::D::test_d PASSED',
- 'test_one.py::C::test_c PASSED',
- 'test_one.py::A::test_a PASSED',
- 'test_one.py::B::test_b PASSED',
+ "test_one.py::D::test_d PASSED",
+ "test_one.py::C::test_c PASSED",
+ "test_one.py::A::test_a PASSED",
+ "test_one.py::B::test_b PASSED",
]
@@ -317,16 +319,16 @@
pass
"""
)
- args = ['-v', '--randomly-seed=15']
+ args = ["-v", "--randomly-seed=15"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=4, failed=0)
assert out.outlines[8:12] == [
- 'test_one.py::T::test_d PASSED',
- 'test_one.py::T::test_c PASSED',
- 'test_one.py::T::test_a PASSED',
- 'test_one.py::T::test_b PASSED',
+ "test_one.py::T::test_d PASSED",
+ "test_one.py::T::test_c PASSED",
+ "test_one.py::T::test_a PASSED",
+ "test_one.py::T::test_b PASSED",
]
@@ -346,16 +348,16 @@
pass
"""
)
- args = ['-v', '--randomly-seed=15']
+ args = ["-v", "--randomly-seed=15"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=4, failed=0)
assert out.outlines[8:12] == [
- 'test_one.py::test_d PASSED',
- 'test_one.py::test_c PASSED',
- 'test_one.py::test_a PASSED',
- 'test_one.py::test_b PASSED',
+ "test_one.py::test_d PASSED",
+ "test_one.py::test_c PASSED",
+ "test_one.py::test_a PASSED",
+ "test_one.py::test_b PASSED",
]
@@ -380,16 +382,16 @@
pass
"""
)
- args = ['-v', '--randomly-seed=15']
+ args = ["-v", "--randomly-seed=15"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=4, failed=0)
assert out.outlines[8:12] == [
- 'test_one.py::test_d PASSED',
- 'test_one.py::test_c PASSED',
- 'test_one.py::test_a PASSED',
- 'test_one.py::test_b PASSED',
+ "test_one.py::test_d PASSED",
+ "test_one.py::test_c PASSED",
+ "test_one.py::test_a PASSED",
+ "test_one.py::test_b PASSED",
]
@@ -411,13 +413,13 @@
return 9002
"""
)
- args = ['-v', '--doctest-modules', '--randomly-seed=5']
+ args = ["-v", "--doctest-modules", "--randomly-seed=5"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=2)
assert out.outlines[8:10] == [
- 'test_one.py::test_one.bar PASSED',
- 'test_one.py::test_one.foo PASSED',
+ "test_one.py::test_one.bar PASSED",
+ "test_one.py::test_one.foo PASSED",
]
@@ -459,28 +461,32 @@
)
"""
)
- args = ['-v']
+ args = ["-v"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=2)
def test_doctests_in_txt_files_reordered(ourtestdir):
- ourtestdir.tmpdir.join('test.txt').write('''\
+ ourtestdir.tmpdir.join("test.txt").write(
+ """\
>>> 2 + 2
4
- ''')
- ourtestdir.tmpdir.join('test2.txt').write('''\
+ """
+ )
+ ourtestdir.tmpdir.join("test2.txt").write(
+ """\
>>> 2 - 2
0
- ''')
- args = ['-v', '--randomly-seed=1']
+ """
+ )
+ args = ["-v", "--randomly-seed=1"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=2)
assert out.outlines[8:10] == [
- 'test2.txt::test2.txt PASSED',
- 'test.txt::test.txt PASSED',
+ "test2.txt::test2.txt PASSED",
+ "test.txt::test.txt PASSED",
]
@@ -532,14 +538,14 @@
assert random.getstate() == state_at_seed_two
"""
)
- args = ['--randomly-seed=2']
+ args = ["--randomly-seed=2"]
out = ourtestdir.runpytest(*args)
out.assert_outcomes(passed=2)
- out = ourtestdir.runpytest('-m', 'one', *args)
+ out = ourtestdir.runpytest("-m", "one", *args)
out.assert_outcomes(passed=1)
- out = ourtestdir.runpytest('-m', 'two', *args)
+ out = ourtestdir.runpytest("-m", "two", *args)
out.assert_outcomes(passed=1)
@@ -564,7 +570,7 @@
"""
)
- out = ourtestdir.runpytest('--randomly-seed=1')
+ out = ourtestdir.runpytest("--randomly-seed=1")
out.assert_outcomes(passed=2)
@@ -583,7 +589,7 @@
"""
)
- out = ourtestdir.runpytest('--randomly-seed=1')
+ out = ourtestdir.runpytest("--randomly-seed=1")
out.assert_outcomes(passed=2)
@@ -600,7 +606,7 @@
"""
)
- out = ourtestdir.runpytest('--randomly-seed=1')
+ out = ourtestdir.runpytest("--randomly-seed=1")
out.assert_outcomes(passed=2)
@@ -616,3 +622,41 @@
modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',")
with pytest.raises(ImportError):
modcol.obj
+
+
+def test_entrypoint_injection(testdir, monkeypatch):
+ """Test that registered entry points are seeded"""
+
+ class _FakeEntryPoint(object):
+ """Minimal surface of Entry point API to allow testing"""
+
+ def __init__(self, name, obj):
+ self.name = name
+ self._obj = obj
+
+ def load(self):
+ return self._obj
+
+ class _FakeEntrypoints(object):
+ """Minimal surface of entrypoints to allow testing"""
+
+ def __init__(self):
+ self._entrypoints = []
+
+ def add_entry_point(self, name, function):
+ self._entrypoints.append(_FakeEntryPoint(name, function))
+
+ def get_group_all(self, name):
+ assert name == "pytest_randomly.random_seeder"
+ return self._entrypoints
+
+ fake_entrypoints = _FakeEntrypoints()
+ monkeypatch.setattr(pytest_randomly, "entrypoints", fake_entrypoints)
+ reseed = Mock()
+ fake_entrypoints.add_entry_point("test_seeder", reseed)
+
+ # Need to run in-process so that monkeypatching works
+ testdir.runpytest("--randomly-seed=1")
+ assert reseed.call_args == ((1,),)
+ testdir.runpytest("--randomly-seed=424242")
+ assert reseed.call_args == ((424242,),)