Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Remove py3.5 compat from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sambhav committed Sep 6, 2020
1 parent 7146353 commit 52e1e10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 42 deletions.
11 changes: 0 additions & 11 deletions src/tests/test_cases/fstrings.py36

This file was deleted.

36 changes: 5 additions & 31 deletions src/tests/test_definitions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Old parser tests."""

import sys
import os
import os.path
import re
import pytest
from pydocstyle.violations import Error, ErrorRegistry
Expand All @@ -26,41 +24,17 @@
'canonical_numpy_examples',
'canonical_pep257_examples',
])
def test_all_interpreters(test_case):
"""Complex test cases that run under all interpreters."""
run_case(test_case)


@pytest.mark.skipif(
sys.version_info < (3, 6),
reason="f-string support needed"
)
def test_fstrings():
"""Run the f-string test case under Python 3.6+ only."""
# When run under Python 3.5, mypy reports a parse error for the test file,
# because Python 3.5 doesn't support f-strings. It does not support
# ignoring parse errors.
#
# To work around this, we put our code in a file that mypy cannot see. This
# code reveals it to Python.
from . import test_cases
import importlib.machinery
test_cases_dir = test_cases.__path__[0]
loader = sys.path_importer_cache[test_cases_dir]
loader._loaders.append(('.py36', importlib.machinery.SourceFileLoader))

run_case('fstrings')


def run_case(test_case):
def test_complex_file(test_case):
"""Run domain-specific tests from test.py file."""
case_module = __import__(f'test_cases.{test_case}',
globals=globals(),
locals=locals(),
fromlist=['expectation'],
level=1)

test_case_file = os.path.relpath(case_module.__file__)
test_case_dir = os.path.normcase(os.path.dirname(__file__))
test_case_file = os.path.join(test_case_dir,
'test_cases',
test_case + '.py')
results = list(check([test_case_file],
select=set(ErrorRegistry.get_error_codes()),
ignore_decorators=re.compile(
Expand Down

0 comments on commit 52e1e10

Please sign in to comment.