Commit Graph

23 Commits

Author SHA1 Message Date
Bruno Oliveira 07f5f6fd4a
Merge pull request #7481 from bluetech/tw-unicode-escape
terminalwriter: bring back handling of printing characters not supported by stdout
2020-07-11 16:01:45 -03:00
Ran Benita 7b65b2337b
Merge pull request #7472 from bluetech/cleanups-4
Some minor fixes & type annotations
2020-07-11 19:05:07 +03:00
Ran Benita 113339b029 terminalwriter: bring back handling of printing characters not supported by stdout 2020-07-11 18:59:00 +03:00
Hugo van Kemenade c1c5a2b34a
Add support for NO_COLOR and FORCE_COLOR (#7466)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-10 08:49:10 -03:00
Ran Benita a2f021b6f3 Remove no longer needed `noqa: F821` uses
Not needed since pyflakes 2.2.0.
2020-07-10 13:08:56 +03:00
gdhameeja 03230b4002 Fix-6906: Added code-highlight option to disable highlighting optionally
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-26 13:24:56 -07:00
Ran Benita 54ad048be7 Enable check_untyped_defs mypy option for testing/ too 2020-06-05 11:34:20 +03:00
Ran Benita aca534c67d Improve our own wcwidth implementation and remove dependency on wcwidth package
`TerminalWriter`, imported recently from `py`, contains its own
incomplete wcwidth (`char_with`/`get_line_width`) implementation. The
`TerminalReporter` also needs this, but uses the external `wcwidth`
package.

This commit brings the `TerminalWriter` implementation up-to-par with
`wcwidth`, moves to implementation to a new file `_pytest._io.wcwidth`
which is used everywhere, and removes the dependency.

The differences compared to the `wcwidth` package are:

- Normalizes the string before counting.

- Uses Python's `unicodedata` instead of vendored Unicode tables. This
  means the data corresponds to the Python's version Unicode version
  instead of the `wcwidth`'s package version.

- Apply some optimizations.
2020-05-26 17:14:01 +03:00
Bruno Oliveira 6c2d358918
Merge pull request #7135 from pytest-dev/terminalwriter 2020-05-06 18:26:44 -03:00
Bruno Oliveira d0022b5a13 'saferepr' handles classes with broken __getattribute__
Fix #7145
2020-05-05 19:22:39 -03:00
Ran Benita d8558e87c5 terminalwriter: clean up markup function a bit 2020-04-30 16:44:03 +03:00
Ran Benita bafc9bd58b testing: merge code/test_terminal_writer.py into io/test_terminalwriter.py 2020-04-30 16:44:03 +03:00
Ran Benita 0e36596268 testing/io: port TerminalWriter tests from py 2020-04-30 16:44:03 +03:00
Daniel Hahler b7ad4c2bed
_pformat_dispatch: pass through args (#6715) 2020-02-12 16:07:57 +01:00
Daniel Hahler fee7c7b032 py38: do not call None() directly
Works around:

    _____ ERROR collecting testing/io/test_saferepr.py _____
    src/_pytest/python.py:502: in _importtestmodule
        mod = self.fspath.pyimport(ensuresyspath=importmode)
    .venv38/lib/python3.8/site-packages/py/_path/local.py:701: in pyimport
        __import__(modname)
    <frozen importlib._bootstrap>:991: in _find_and_load
        ???
    <frozen importlib._bootstrap>:975: in _find_and_load_unlocked
        ???
    <frozen importlib._bootstrap>:671: in _load_unlocked
        ???
    src/_pytest/assertion/rewrite.py:136: in exec_module
        source_stat, co = _rewrite_test(fn, self.config)
    src/_pytest/assertion/rewrite.py:288: in _rewrite_test
        co = compile(tree, fn, "exec", dont_inherit=True)
    E     File "…/Vcs/pytest/testing/io/test_saferepr.py", line 45
    E       None()
    E       ^
    E   SyntaxError: 'NoneType' object is not callable; perhaps you missed a comma?
2019-11-06 22:08:10 +01:00
Daniel Hahler eb7a4e32ad saferepr: handle BaseExceptions
This causes INTERNALERRORs with pytest-django, which uses
`pytest.fail` (derived from `BaseException`) to prevent DB access, when
pytest then tries to e.g. display the `repr()` for a Django `QuerySet`
etc.

Ref: https://github.com/pytest-dev/pytest-django/pull/776
2019-11-06 22:08:10 +01:00
Ran Benita 129600d698 saferepr: Avoid indirect function calls
The DRY savings they provide are rather small, while they make it harder
to type-check, and IMO harder to understand.
2019-07-15 17:07:58 +03:00
Ran Benita 0394ebffee saferepr: Use an __init__ instead of setting attributes after construction
This will be easier to type-check, and also somewhat clearer.
2019-07-14 22:50:14 +03:00
Anthony Sottile ccd87f9e80 small mypy fixes 2019-06-06 09:13:02 -07:00
Anthony Sottile a91fe1fedd pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
Anthony Sottile 5034399d7a pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03:00
Anthony Sottile 095ce2ca7f Fix linting errors and py references in saferepr.py 2019-01-20 16:36:14 -08:00
Anthony Sottile dbb6c18c44 copy saferepr from pylib verbatim
Copied from b9da2ed6178cd37d4ed6b41f9fa8234dce96973f
2019-01-20 16:30:31 -08:00