summaryrefslogtreecommitdiff
path: root/src/_pytest/_io
AgeCommit message (Collapse)Author
2020-12-30[pre-commit.ci] pre-commit autoupdate (#8201)pre-commit-ci[bot]
* [pre-commit.ci] pre-commit autoupdate * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * manual fixes after configuration update * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Anthony Sottile <asottile@umich.edu>
2020-10-05py36+: com2annAnthony Sottile
2020-10-03py36+: pyupgrade: py36+Anthony Sottile
2020-10-03py36+: update the target version of black to py36Anthony Sottile
2020-09-22Mark some public and to-be-public classes as `@final`Ran Benita
This indicates at least for people using type checkers that these classes are not designed for inheritance and we make no stability guarantees regarding inheritance of them. Currently this doesn't show up in the docs. Sphinx does actually support `@final`, however it only works when imported directly from `typing`, while we import from `_pytest.compat`. In the future there might also be a `@sealed` decorator which would cover some more cases.
2020-08-01Format docstrings in a consistent styleRan Benita
2020-07-11Merge pull request #7481 from bluetech/tw-unicode-escapeBruno Oliveira
terminalwriter: bring back handling of printing characters not supported by stdout
2020-07-11Merge pull request #7472 from bluetech/cleanups-4Ran Benita
Some minor fixes & type annotations
2020-07-11terminalwriter: bring back handling of printing characters not supported by ↵Ran Benita
stdout
2020-07-10Add support for NO_COLOR and FORCE_COLOR (#7466)Hugo van Kemenade
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-10Remove no longer needed `noqa: F821` usesRan Benita
Not needed since pyflakes 2.2.0.
2020-06-26Fix-6906: Added code-highlight option to disable highlighting optionallygdhameeja
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-05Type annotate _pytest._io.safereprRan Benita
2020-05-26Improve our own wcwidth implementation and remove dependency on wcwidth packageRan Benita
`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-06Merge pull request #7135 from pytest-dev/terminalwriterBruno Oliveira
2020-05-05'saferepr' handles classes with broken __getattribute__Bruno Oliveira
Fix #7145
2020-04-30terminalwriter: clean up markup function a bitRan Benita
2020-04-30config/argparsing: use our own get_terminal_width()Ran Benita
2020-04-30terminalwriter: compute width_of_current_line lazilyRan Benita
Currently this property is computed eagerly, which means get_line_width() is computed on everything written, but that is a slow function. Compute it lazily, so that get_line_width() only runs when needed.
2020-04-30terminalwriter: remove unused property chars_on_current_lineRan Benita
2020-04-30terminalwriter: don't flush implicitly; add explicit flushesRan Benita
Flushing on every write is somewhat expensive. Rely on line buffering instead (if line buffering for stdout is disabled, there must be some reason...), and add explicit flushes when not outputting lines. This is how regular `print()` e.g. work so should be familiar.
2020-04-30terminalwriter: inline function _update_chars_on_current_lineRan Benita
2020-04-30terminalwriter: remove unneeded hasattr useRan Benita
2020-04-30terminalwriter: add type annotationsRan Benita
2020-04-30terminalwriter: remove win32 specific code in favor of relying on coloramaRan Benita
On Windows we already depend on colorama, which takes care of all of this custom code on its own.
2020-04-30terminalwriter: inline function _escapedRan Benita
Doesn't add much.
2020-04-30terminalwriter: remove TerminalWriter's stringio argumentRan Benita
Had a mark indicating it should be removed, and I agree, it's better to just use the `file` argument.
2020-04-30io: combine _io.TerminalWriter and _io.terminalwriter.TerminalWriterRan Benita
Previously it extended an external type but now it come move to the type itself.
2020-04-30terminalwriter: remove support for passing callable as file in TerminalWriterRan Benita
Not used.
2020-04-30terminalwriter: remove unused function TerminalWriter.relineRan Benita
2020-04-30terminalwriter: remove unused function ansi_printRan Benita
2020-04-30terminalwriter: remove support for writing bytes directlyRan Benita
It is not used and slows things down.
2020-04-30terminalwriter: optimize get_line_width() a bitRan Benita
This function is called a lot when printing a lot of text, and is very slow -- this speeds it up a bit.
2020-04-30terminalwriter: simplify get_terminal_width()Ran Benita
The shutil.get_terminal_size() handles everything this did already.
2020-04-30terminalwriter: remove custom win32 screen width codeRan Benita
Python 3 does this on its own so we can use the shared code: https://github.com/python/cpython/commit/bcf2b59fb5f18c09a26da3e9b60a37367f2a28ba
2020-04-30terminalwriter: move Win32ConsoleWriter definition under win32 conditionalRan Benita
This way non-Windows platforms skip it. It also uses things defined inside the `if`.
2020-04-30terminalwriter: fix lintsRan Benita
2020-04-30terminalwriter: auto-formatRan Benita
2020-04-30terminalwriter: vendor TerminalWriter from pyRan Benita
Straight copy from py 1.8.1. Doesn't pass linting yet.
2020-02-20Assorted improvements following up #6658Bruno Oliveira
2020-02-12_pformat_dispatch: pass through args (#6715)Daniel Hahler
2020-02-12Use code highlighting if pygments is installed (#6658)Bruno Oliveira
* Use code highlighting if pygments is installed * Use colorama constants instead of bare ascii codes Could not find the exact equivalent of 'hl-reset' code using colorama constants though. * Refactor ASCII color handling into a fixture * Revert back to using explicit color codes * In Python 3.5 skip rest of tests that require ordered markup in colored output
2020-01-24Merge master into featuresDaniel Hahler
Conflicts: src/_pytest/_code/code.py src/_pytest/main.py
2020-01-23config: typing for create_terminal_writer, re-export TerminalWriterDaniel Hahler
This also imports `TerminalWriter` explicitly via `_pytest._io`, allowing for easier extending / replacing it.
2019-11-20minor: move internal _pformat_dispatch functionDaniel Hahler
2019-11-06saferepr: handle BaseExceptionsDaniel Hahler
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-03Add type annotations to _pytest._io.safereprRan Benita
2019-07-15saferepr: Avoid indirect function callsRan Benita
The DRY savings they provide are rather small, while they make it harder to type-check, and IMO harder to understand.
2019-07-14saferepr: Remove unused setting of max_otherRan Benita
max_other is used by the superclass repr_instance, but we override it and use maxsize instead.
2019-07-14saferepr: Use an __init__ instead of setting attributes after constructionRan Benita
This will be easier to type-check, and also somewhat clearer.