summaryrefslogtreecommitdiff
path: root/testing/test_assertion.py
AgeCommit message (Collapse)Author
2020-10-31Add support to display field names in namedtuple diffs.Karthikeyan Singaravelan
2020-10-29Migrate test_assertion.py from testdir to pytesterChristine Mecklenborg
2020-10-05py36+: com2annAnthony Sottile
2020-10-03py36+: pyupgrade: py36+Anthony Sottile
2020-10-02py36+: resolve py36 TODOsAnthony Sottile
2020-09-27Bump attrs requirement from >=17.4.0 to >=19.2.0Ran Benita
This allows us to remove the `ATTRS_EQ_FIELD` thing which is causing some annoyance.
2020-08-03testing: fix some docstring issuesRan Benita
In preparation for enforcing some docstring lints.
2020-08-01typing: set disallow_any_genericsRan Benita
This prevents referring to a generic type without filling in its generic type parameters. The FixtureDef typing might need some more refining in the future.
2020-07-08assertion: improve diff output of recursive dataclass/attrsVlad-Radz
Co-authored-by: Vlad <uladzislau.radziuk@nordcloud.com>
2020-06-21parametrize test_warn_missing for a cleaner testGleb Nikonorov
2020-06-20add test_warn_missing case for --assert=plainGleb Nikonorov
2020-06-20remove extra whitespaceGleb Nikonorov
2020-06-20replace stderr warnings with the warnings moduleGleb Nikonorov
2020-06-09Fix mypy checksBruno Oliveira
2020-06-09Update testing/test_assertion.pyRan Benita
2020-06-09Make dataclasses/attrs comparison recursive, fixes #4675ibriquem
2020-06-05Enable check_untyped_defs mypy option for testing/ tooRan Benita
2020-04-08Remove some no-longer-needed compat code in test_assertionRan Benita
2020-04-04Fix tests: use explicit syspathinsert where tests might hang (#7008)Daniel Hahler
Use `testdir.syspathinsert()` with multiprocessing tests: - test_chained_exceptions_no_reprcrash - test_exception_handling_no_traceback This only works currently because `_importtestmodule` changes `sys.path` as a side-effect. It appears to be only required on Windows though - likely due to the multiprocessing method used there.
2020-03-08tests: harden test_reprcompare_notin, factor out callop (#6764)Daniel Hahler
* tests: assertion: factor out `callop`, typing * tests: harden test_reprcompare_notin
2020-02-24test_assertion: harden/improve test_{text_diff,unicode} (#6806)Daniel Hahler
2020-02-22test_reprcompare_whitespaces: use callequalDaniel Hahler
2020-02-14assertrepr_compare: provide more info (location) with exceptions (#6728)Daniel Hahler
2020-02-12Merge pull request #6673 from sscherfke/featuresBruno Oliveira
Reverse / fix meaning of "+/-" in error diffs
2020-02-10Reverse / fix meaning of "+/-" in error diffsStefan Scherfke
The convention is "assert result is expected". Pytest's error diffs now reflect this. "-" means that sth. expected is missing in the result and "+" means that there are unexpected extras in the result. Fixes: #3333
2020-02-04assertion: save/restore hooks on item (#6646)Daniel Hahler
2020-01-23tests: remove unnecessary `-rw` optionDaniel Hahler
Warnings are enabled by default, which is tested by `test_getreportopt`.
2020-01-16tests: cleanup unused fixturesDaniel Hahler
2019-11-13pytester: Hookrecorder: improve assertoutcomeDaniel Hahler
Before: def assertoutcome(self, passed: int = 0, skipped: int = 0, failed: int = 0) -> None: realpassed, realskipped, realfailed = self.listoutcomes() assert passed == len(realpassed) > assert skipped == len(realskipped) E assert 1 == 0 E + where 0 = len([]) After: > reprec = testdir.inline_run(testpath, "-s") E AssertionError: ([], [], [<TestReport 'nodeid' when='call' outcome='failed'>]) E assert {'failed': 1, 'passed': 0, 'skipped': 0} == {'failed': 0, 'passed': 0, 'skipped': 1}
2019-11-08_compare_eq_iterable: use AlwaysDispatchingPrettyPrinterDaniel Hahler
This fixes/removes the previous hack of re-trying with minimum width, which fails short when it splits strings. This inherits from `pprint.PrettyPrinter` to override `_format` in a minimal way to always dispatch, regardless of the given width. Code ref: https://github.com/python/cpython/blob/5c0c325453a175350e3c18ebb10cc10c37f9595c/Lib/pprint.py#L170-L178
2019-11-07test_iterable_full_diff: use test idsDaniel Hahler
2019-11-06assert: fix _compare_eq_iterable: re-format both sidesDaniel Hahler
Follow-up to 946434c61 (#5924). Before this patch the test would look like this: {'env': {'sub...s wrapped'}}}} == {'env': {'sub...}}}, 'new': 1} Omitting 1 identical items, use -vv to show Right contains 1 more item: {'new': 1} Full diff: { 'env': {'sub': {'long_a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'sub1': {'long_a': 'substring ' + 'sub1': {'long_a': 'substring that gets wrapped'}}}, ? +++++++++++++++++ ++++ + 'new': 1, - 'that ' - 'gets ' - 'wrapped'}}}, }
2019-10-11test_assertion: improve mock_configDaniel Hahler
2019-10-08Improve full diff output for listsDaniel Hahler
Massage text input for difflib when comparing pformat output of different line lengths. Also do not strip ndiff output on the left, which currently already removes indenting for lines with no differences. Before: E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] E Right contains 3 more items, first extra item: ' ' E Full diff: E - ['version', 'version_info', 'sys.version', 'sys.version_info'] E + ['version', E + 'version_info', E + 'sys.version', E + 'sys.version_info', E + ' ', E + 'sys.version', E + 'sys.version_info'] After: E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...] E Right contains 3 more items, first extra item: ' ' E Full diff: E [ E 'version', E 'version_info', E 'sys.version', E 'sys.version_info', E + ' ', E + 'sys.version', E + 'sys.version_info', E ]
2019-10-06Use new no-match functions to replace previous idiomBruno Oliveira
2019-10-05Use ATTRS_EQ_FIELD for attrs 19.2 compatAnthony Sottile
2019-10-01Fix warnings with attrs 19.2 and fix object assertionsHynek Schlawack
attrs 19.2 deprecated cmp in favor of the dataclass-ish eq/order duo. This causes deprecation warnings that in turn break some of the cool new deep object comparisons. Since we at attrs expected this to be a problem, it shipped with helpers to write backward and forward compatible code. This PR uses that and avoids changed to minimal versions.
2019-08-17test_assertion: minor cleanupDaniel Hahler
2019-08-17Fix wrong location of assertion error with coverage.pyDaniel Hahler
Reverts using-constant part from 39ba99613. Fixes https://github.com/pytest-dev/pytest/issues/5754.
2019-07-04Replace importlib_metadata with importlib.metadata on Python 3.8+Miro HronĨok
Fixes https://github.com/pytest-dev/pytest/issues/5537
2019-06-25Show bytes ascii representation instead of numeric valueBruno Oliveira
2019-06-25Fix/improve comparison of byte stringsDaniel Hahler
Fixes https://github.com/pytest-dev/pytest/issues/5260.
2019-06-24Switch from deprecated imp to importlibAnthony Sottile
2019-06-04Clean up u' prefixes and py2 bytes conversionsAnthony Sottile
2019-06-03Clean up __future__ and coding: in testsAnthony Sottile
2019-06-03pre-commit run pyupgrade --all-filesAnthony Sottile
2019-06-03pre-commit run reorder-python-imports --all-filesAnthony Sottile
2019-06-03pre-commit run fix-encoding-pragma --all-filesAnthony Sottile
2019-06-02Drop Python 2.7 and 3.4 supportBruno Oliveira
* Update setup.py requires and classifiers * Drop Python 2.7 and 3.4 from CI * Update docs dropping 2.7 and 3.4 support * Fix mock imports and remove tests related to pypi's mock module * Add py27 and 34 support docs to the sidebar * Remove usage of six from tmpdir * Remove six.PY* code blocks * Remove sys.version_info related code * Cleanup compat * Remove obsolete safe_str * Remove obsolete __unicode__ methods * Remove compat.PY35 and compat.PY36: not really needed anymore * Remove unused UNICODE_TYPES * Remove Jython specific code * Remove some Python 2 references from docs Related to #5275
2019-05-27Switch to importlib-metadataAnthony Sottile