Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ repos:
additional_dependencies: [black==19.3b0]
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
rev: v2.2.2
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: check-yaml
- id: debug-statements
exclude: _pytest/debugging.py
Expand Down
1 change: 1 addition & 0 deletions bench/bench.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions bench/bench_argcomplete.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# 10000 iterations, just for relative comparison
# 2.7.5 3.3.2
# FilesCompleter 75.1109 69.2116
Expand Down
1 change: 1 addition & 0 deletions bench/empty.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# -*- coding: utf-8 -*-
for i in range(1000):
exec("def test_func_%d(): pass" % i)
1 change: 1 addition & 0 deletions bench/manyparam.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import pytest


Expand Down
1 change: 1 addition & 0 deletions bench/skip.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from six.moves import range

import pytest
Expand Down
1 change: 1 addition & 0 deletions doc/en/_themes/flask_theme_support.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Comment
Expand Down
1 change: 1 addition & 0 deletions doc/en/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# -*- coding: utf-8 -*-
collect_ignore = ["conf.py"]
1 change: 1 addition & 0 deletions doc/en/example/assertion/failure_demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import _pytest._code
import pytest
from pytest import raises
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import py

import pytest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
hello = "world"


Expand Down
1 change: 1 addition & 0 deletions doc/en/example/assertion/test_failures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import py

failure_demo = py.path.local(__file__).dirpath("failure_demo.py")
Expand Down
1 change: 1 addition & 0 deletions doc/en/example/assertion/test_setup_flow_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
def setup_module(module):
module.TestStateFullThing.classcount = 0

Expand Down
1 change: 1 addition & 0 deletions doc/en/example/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# -*- coding: utf-8 -*-
collect_ignore = ["nonpython"]
1 change: 1 addition & 0 deletions doc/en/example/costlysetup/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import pytest


Expand Down
1 change: 1 addition & 0 deletions doc/en/example/costlysetup/sub_a/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# -*- coding: utf-8 -*-
#
1 change: 1 addition & 0 deletions doc/en/example/costlysetup/sub_a/test_quick.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# -*- coding: utf-8 -*-
def test_quick(setup):
pass
1 change: 1 addition & 0 deletions doc/en/example/costlysetup/sub_b/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# -*- coding: utf-8 -*-
#
1 change: 1 addition & 0 deletions doc/en/example/costlysetup/sub_b/test_two.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
def test_something(setup):
assert setup.timecostly == 1

Expand Down
1 change: 1 addition & 0 deletions doc/en/example/multipython.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
module containing a parametrized tests testing cross-python
serialization via the pickle module.
Expand Down
1 change: 1 addition & 0 deletions doc/en/example/nonpython/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# content of conftest.py
import pytest

Expand Down
1 change: 1 addition & 0 deletions doc/en/example/py2py3/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys

import pytest
Expand Down
1 change: 1 addition & 0 deletions doc/en/example/py2py3/test_py3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
def test_exception_syntax():
try:
0 / 0
Expand Down
1 change: 1 addition & 0 deletions doc/en/example/pythoncollection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# run this with $ pytest --collect-only test_collectonly.py
#

Expand Down
1 change: 1 addition & 0 deletions doc/en/example/xfail_demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import pytest

xfail = pytest.mark.xfail
Expand Down
1 change: 1 addition & 0 deletions extra/get_issues.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import json

import py
Expand Down
1 change: 1 addition & 0 deletions extra/setup-py.test/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys
from distutils.core import setup

Expand Down
1 change: 1 addition & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Invoke development tasks.
"""
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from setuptools import setup

# TODO: if py gets upgrade to >=1.6,
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
__all__ = ["__version__"]

try:
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/_argcomplete.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""allow bash-completion for argparse with argcomplete if installed
needs argcomplete>=0.5.6 for python 3.2/3.3 (older versions fail
to find the magic string, so _ARGCOMPLETE env. var is never set, and
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/_code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" python inspection/code generation API """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/_code/_py2traceback.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# copied from python-2.7.3's traceback.py
# CHANGES:
# - some_str is replaced, trying to create unicode strings
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/_code/source.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/_io/saferepr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import pprint

from six.moves import reprlib
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/assertion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
support for presenting detailed information in failing assertions.
"""
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Rewrite assertion AST to produce nice error messages"""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/assertion/truncate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Utilities for truncating assertion output.

Expand Down
1 change: 1 addition & 0 deletions src/_pytest/assertion/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Utilities for assertion debugging"""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
merged implementation of the cache provider

Expand Down
1 change: 1 addition & 0 deletions src/_pytest/capture.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
per-test stdout/stderr capturing mechanism.

Expand Down
1 change: 1 addition & 0 deletions src/_pytest/compat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
python version compatibility code
"""
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" command line options, ini-file and conftest.py processing. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/config/argparsing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import argparse
import warnings

Expand Down
1 change: 1 addition & 0 deletions src/_pytest/config/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
class UsageError(Exception):
""" error in pytest usage or invocation"""

Expand Down
1 change: 1 addition & 0 deletions src/_pytest/config/findpaths.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os

import py
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/debugging.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" interactive debugging with PDB, the Python Debugger. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/deprecated.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
This module contains deprecation messages and bits of code used elsewhere in the codebase
that is planned to be removed in the next pytest release.
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/doctest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" discover and run doctests in modules and test files."""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/freeze_support.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Provides a function to report all internal modules for using freezing tools
pytest
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/helpconfig.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" version info, help messages, tracing configuration. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/hookspec.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" hook specifications for pytest plugins, invoked from main.py and builtin plugins. """
from pluggy import HookspecMarker

Expand Down
1 change: 1 addition & 0 deletions src/_pytest/junitxml.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
report test results in JUnit-XML format,
for use with Jenkins and build integration servers.
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/logging.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" Access and control log capturing. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" core implementation of testing process: init, session, runtest loop. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/mark/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" generic mechanism for marking and selecting python functions. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/mark/evaluate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os
import platform
import sys
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/mark/legacy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
this is a place where we put datastructures used by legacy apis
we hope ot remove
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import inspect
import warnings
from collections import namedtuple
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/monkeypatch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" monkeypatching and mocking functionality. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/nodes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/nose.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" run test suites written for nose. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/outcomes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
exception classes and constants handling test outcomes
as well as functions creating them
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/pastebin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" submit failure or test session information to a pastebin service. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/pathlib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import atexit
import errno
import fnmatch
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/pytester.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""(disabled by default) support for testing pytest and pytest plugins."""
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" Python test discovery, setup and run of test functions. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/python_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import math
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/recwarn.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" recording warnings during test function execution. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/reports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from pprint import pprint

import py
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/resultlog.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" log machine-parseable test session result information in a plain
text file.
"""
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" basic collect and runtest protocol implementations """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/setuponly.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/setupplan.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/skipping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding=utf8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use fix-encoding-pragma from pre-commit/pre-commit-hooks

(yep, there's a pre-commit hook for everything!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good! Could you please contribute that in place of this PR then? 😁

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it only do it if necessary maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency it's all or none, that way you don't have to think about it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the main point of pre-commit already that "you don't have to think about it", i.e. you do not have to care, and it will insert/request it if necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah so now you don't have to futz with whether a file has it or not, it always has it

# -*- coding: utf-8 -*-
""" support for skip/xfail functions and markers. """
from __future__ import absolute_import
from __future__ import division
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/stepwise.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import pytest


Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/terminal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
# -*- coding: utf-8 -*-
""" terminal reporting of the full testing process.

This is a good source for looking at the various reporting hooks.
Expand Down
1 change: 1 addition & 0 deletions src/_pytest/tmpdir.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" support for providing temporary directories to test functions. """
from __future__ import absolute_import
from __future__ import division
Expand Down
Loading