diff --git a/.travis.yml b/.travis.yml index 4b3736793b3..5ec4b273562 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,81 +18,9 @@ install: jobs: include: - # OSX tests - first (in test stage), since they are the slower ones. - - &test-macos - os: osx - osx_image: xcode10.1 - language: generic - # Coverage for: - # - py2 with symlink in test_cmdline_python_package_symlink. - env: TOXENV=py27-xdist PYTEST_COVERAGE=1 - before_install: - - python -V - - test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 27 - - <<: *test-macos - env: TOXENV=py37-pexpect,py37-xdist PYTEST_COVERAGE=1 - before_install: - - which python3 - - python3 -V - - ln -sfn "$(which python3)" /usr/local/bin/python - - python -V - - test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37 - - # Full run of latest (major) supported versions, without xdist. - - env: TOXENV=py27 - python: '2.7' - - env: TOXENV=py37 - python: '3.7' - - # Coverage tracking is slow with pypy, skip it. - - env: TOXENV=pypy-xdist - python: 'pypy' - - env: TOXENV=pypy3-xdist + - env: TOXENV=pypy3 python: 'pypy3' - - env: TOXENV=py34-xdist - python: '3.4' - - env: TOXENV=py35-xdist - python: '3.5' - - # Coverage for: - # - pytester's LsofFdLeakChecker - # - TestArgComplete (linux only) - # - numpy - # Empty PYTEST_ADDOPTS to run this non-verbose. - - env: TOXENV=py37-lsof-numpy-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS= - - # Specialized factors for py27. - - env: TOXENV=py27-nobyte-numpy-xdist - python: '2.7' - - env: TOXENV=py27-pluggymaster-xdist - python: '2.7' - - # Specialized factors for py37. - # Coverage for: - # - test_sys_breakpoint_interception (via pexpect). - - env: TOXENV=py37-pexpect,py37-twisted PYTEST_COVERAGE=1 - - env: TOXENV=py37-pluggymaster-xdist - - env: TOXENV=py37-freeze - - # Jobs only run via Travis cron jobs (currently daily). - - env: TOXENV=py38-xdist - python: '3.8-dev' - if: type = cron - - - stage: baseline - # Coverage for: - # - _pytest.unittest._handle_skip (via pexpect). - env: TOXENV=py27-pexpect,py27-twisted PYTEST_COVERAGE=1 - python: '2.7' - # Use py36 here for faster baseline. - - env: TOXENV=py36-xdist - python: '3.6' - - env: TOXENV=linting,docs,doctesting PYTEST_COVERAGE=1 - cache: - directories: - - $HOME/.cache/pre-commit - - stage: deploy python: '3.6' install: pip install -U setuptools setuptools_scm @@ -127,7 +55,7 @@ before_script: export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess fi -script: tox --recreate +script: tox -- testing/python after_success: - | diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 8e50486de55..00000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,113 +0,0 @@ -trigger: -- master -- features - -variables: - PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml -vv" - python.needs_vc: False - COVERAGE_FILE: "$(Build.Repository.LocalPath)/.coverage" - COVERAGE_PROCESS_START: "$(Build.Repository.LocalPath)/.coveragerc" - PYTEST_COVERAGE: '0' - -jobs: - -- job: 'Test' - pool: - vmImage: "vs2017-win2016" - strategy: - matrix: - py27: - python.version: '2.7' - tox.env: 'py27' - py27-nobyte-lsof-numpy: - python.version: '2.7' - tox.env: 'py27-lsof-nobyte-numpy' - # Coverage for: - # - test_supports_breakpoint_module_global - # - test_terminal_reporter_writer_attr (without xdist) - # - "if write" branch in _pytest.assertion.rewrite - # - numpy - # - pytester's LsofFdLeakChecker (being skipped) - PYTEST_COVERAGE: '1' - py27-twisted: - python.version: '2.7' - tox.env: 'py27-twisted' - python.needs_vc: True - py27-pluggymaster-xdist: - python.version: '2.7' - tox.env: 'py27-pluggymaster-xdist' - # Coverage for: - # - except-IOError in _attempt_to_close_capture_file for py2. - # Also seen with py27-nobyte (using xdist), and py27-xdist. - # But no exception with py27-pexpect,py27-twisted,py27-numpy. - PYTEST_COVERAGE: '1' - # -- pypy2 and pypy3 are disabled for now: #5279 -- - # pypy: - # python.version: 'pypy2' - # tox.env: 'pypy' - # pypy3: - # python.version: 'pypy3' - # tox.env: 'pypy3' - py34-xdist: - python.version: '3.4' - tox.env: 'py34-xdist' - # Coverage for: - # - _pytest.compat._bytes_to_ascii - PYTEST_COVERAGE: '1' - py35-xdist: - python.version: '3.5' - tox.env: 'py35-xdist' - # Coverage for: - # - test_supports_breakpoint_module_global - PYTEST_COVERAGE: '1' - py36-xdist: - python.version: '3.6' - tox.env: 'py36-xdist' - py37: - python.version: '3.7' - tox.env: 'py37' - # Coverage for: - # - _py36_windowsconsoleio_workaround (with py36+) - # - test_request_garbage (no xdist) - PYTEST_COVERAGE: '1' - py37-linting/docs/doctesting: - python.version: '3.7' - tox.env: 'linting,docs,doctesting' - py37-twisted/numpy: - python.version: '3.7' - tox.env: 'py37-twisted,py37-numpy' - py37-pluggymaster-xdist: - python.version: '3.7' - tox.env: 'py37-pluggymaster-xdist' - maxParallel: 10 - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - architecture: 'x64' - - - script: choco install vcpython27 - condition: eq(variables['python.needs_vc'], True) - displayName: 'Install VC for py27' - - - script: python -m pip install --upgrade pip && python -m pip install tox - displayName: 'Install tox' - - - script: | - call scripts/setup-coverage-vars.bat || goto :eof - python -m tox -e $(tox.env) - displayName: 'Run tests' - - - task: PublishTestResults@2 - inputs: - testResultsFiles: 'build/test-results/$(tox.env).xml' - testRunTitle: '$(tox.env)' - condition: succeededOrFailed() - - - script: call scripts\upload-coverage.bat - displayName: 'Report and upload coverage' - condition: eq(variables['PYTEST_COVERAGE'], '1') - env: - CODECOV_TOKEN: $(CODECOV_TOKEN) - PYTEST_CODECOV_NAME: $(tox.env) diff --git a/changelog/5062.feature.rst b/changelog/5062.feature.rst deleted file mode 100644 index e311d161d52..00000000000 --- a/changelog/5062.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Unroll calls to ``all`` to full for-loops for better failure messages, especially when using Generator Expressions. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 5e2c5397bb8..1c6161b212d 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -953,8 +953,6 @@ def visit_Call_35(self, call): """ visit `ast.Call` nodes on Python3.5 and after """ - if isinstance(call.func, ast.Name) and call.func.id == "all": - return self._visit_all(call) new_func, func_expl = self.visit(call.func) arg_expls = [] new_args = [] @@ -978,27 +976,6 @@ def visit_Call_35(self, call): outer_expl = "%s\n{%s = %s\n}" % (res_expl, res_expl, expl) return res, outer_expl - def _visit_all(self, call): - """Special rewrite for the builtin all function, see #5062""" - if not isinstance(call.args[0], (ast.GeneratorExp, ast.ListComp)): - return - gen_exp = call.args[0] - assertion_module = ast.Module( - body=[ast.Assert(test=gen_exp.elt, lineno=1, msg="", col_offset=1)] - ) - AssertionRewriter(module_path=None, config=None).run(assertion_module) - for_loop = ast.For( - iter=gen_exp.generators[0].iter, - target=gen_exp.generators[0].target, - body=assertion_module.body, - orelse=[], - ) - self.statements.append(for_loop) - return ( - ast.Num(n=1), - "", - ) # Return an empty expression, all the asserts are in the for_loop - def visit_Starred(self, starred): # From Python 3.5, a Starred node can appear in a function call res, expl = self.visit(starred.value) @@ -1009,8 +986,6 @@ def visit_Call_legacy(self, call): """ visit `ast.Call nodes on 3.4 and below` """ - if isinstance(call.func, ast.Name) and call.func.id == "all": - return self._visit_all(call) new_func, func_expl = self.visit(call.func) arg_expls = [] new_args = [] diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 436d786d67a..96292216db3 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1308,6 +1308,9 @@ def parsefactories(self, node_or_obj, nodeid=NOTSET, unittest=False): faclist.insert(i, fixture_def) if marker.autouse: autousenames.append(name) + # CHECK if 'marker' being deleted is the cause for the 'ResourceWarning' errors + # in pypy3 + del marker if autousenames: self._nodeid_and_autousenames.append((nodeid or "", autousenames)) diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 19d050f8769..87dada213d6 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -656,12 +656,6 @@ def __repr__(self): else: assert lines == ["assert 0 == 1\n + where 1 = \\n{ \\n~ \\n}.a"] - def test_unroll_expression(self): - def f(): - assert all(x == 1 for x in range(10)) - - assert "0 == 1" in getmsg(f) - def test_custom_repr_non_ascii(self): def f(): class A(object): @@ -677,53 +671,6 @@ def __repr__(self): assert "UnicodeDecodeError" not in msg assert "UnicodeEncodeError" not in msg - def test_unroll_generator(self, testdir): - testdir.makepyfile( - """ - def check_even(num): - if num % 2 == 0: - return True - return False - - def test_generator(): - odd_list = list(range(1,9,2)) - assert all(check_even(num) for num in odd_list)""" - ) - result = testdir.runpytest() - result.stdout.fnmatch_lines(["*assert False*", "*where False = check_even(1)*"]) - - def test_unroll_list_comprehension(self, testdir): - testdir.makepyfile( - """ - def check_even(num): - if num % 2 == 0: - return True - return False - - def test_list_comprehension(): - odd_list = list(range(1,9,2)) - assert all([check_even(num) for num in odd_list])""" - ) - result = testdir.runpytest() - result.stdout.fnmatch_lines(["*assert False*", "*where False = check_even(1)*"]) - - def test_for_loop(self, testdir): - testdir.makepyfile( - """ - def check_even(num): - if num % 2 == 0: - return True - return False - - def test_for_loop(): - odd_list = list(range(1,9,2)) - for num in odd_list: - assert check_even(num) - """ - ) - result = testdir.runpytest() - result.stdout.fnmatch_lines(["*assert False*", "*where False = check_even(1)*"]) - class TestRewriteOnImport(object): def test_pycache_is_a_file(self, testdir):