Skip to content

Commit

Permalink
remove python 3.6 support (#340)
Browse files Browse the repository at this point in the history
Summary:
Remove python 3.6 support and related ifs

Pull Request resolved: #340

Reviewed By: pedroforjazfigueiredo

Differential Revision: D39852113

Pulled By: deathowl

fbshipit-source-id: 34149c5c2a779a28ea30fec38e8ad48eecbaf0cf
  • Loading branch information
deathowl authored and facebook-github-bot committed Sep 30, 2022
1 parent 6d24595 commit 5ce7b7f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
# Ensure that all flavours are run to completion even if an other flavor failed
fail-fast: false

Expand Down
7 changes: 1 addition & 6 deletions pytest-testslide/tests/test_pytest_testslide.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import re
import sys


def test_pass(testdir):
Expand Down Expand Up @@ -126,11 +125,7 @@ def test_aggregated_exceptions(testslide):
sample_module.CallOrderTarget("c").f1("a")
"""
)
# asyncio-mode is not supported on python3.6
if sys.version_info >= (3, 7):
result = testdir.runpytest("-v", "--asyncio-mode=auto")
else:
result = testdir.runpytest("-v")
result = testdir.runpytest("-v", "--asyncio-mode=auto")
assert "passed, 4 errors" in result.stdout.str()
assert "failed" not in result.stdout.str()
expected_failure = re.compile(
Expand Down
49 changes: 18 additions & 31 deletions tests/dsl_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import asyncio
import os
import subprocess
import sys
import time
import unittest
from typing import List
Expand Down Expand Up @@ -1909,29 +1908,25 @@ async def example(self):
):
self.run_first_context_first_example()

if sys.version_info >= (3, 7):

def test_fail_if_coroutine_not_awaited(self):
@context
def top(context):
@context.example
async def example(self):
asyncio.sleep(0.1)
def test_fail_if_coroutine_not_awaited(self):
@context
def top(context):
@context.example
async def example(self):
asyncio.sleep(0.1)

with self.assertRaisesRegex(
RuntimeWarning, "coroutine '.+' was never awaited"
):
self.run_first_context_first_example()
with self.assertRaisesRegex(RuntimeWarning, "coroutine '.+' was never awaited"):
self.run_first_context_first_example()

def test_fail_if_slow_task(self):
@context
def top(context):
@context.example
async def example(self):
time.sleep(0.1)
def test_fail_if_slow_task(self):
@context
def top(context):
@context.example
async def example(self):
time.sleep(0.1)

with self.assertRaisesRegex(SlowCallback, "^Executing .+ took .+ seconds"):
self.run_first_context_first_example()
with self.assertRaisesRegex(SlowCallback, "^Executing .+ took .+ seconds"):
self.run_first_context_first_example()

def test_resetting_attribute_raises_ValueError(self):
@context
Expand Down Expand Up @@ -2053,11 +2048,7 @@ async def dummy_async_func():
def fail_top(context):
@context.example
async def spawn_task_but_dont_await(self):
if sys.version_info < (3, 7):
loop = asyncio.get_event_loop()
loop.create_task(dummy_async_func())
else:
asyncio.create_task(dummy_async_func())
asyncio.create_task(dummy_async_func())

examples = _get_name_to_examples()

Expand Down Expand Up @@ -2129,11 +2120,7 @@ async def dummy_async_func():
pass

async def spawn_task_but_dont_await():
if sys.version_info < (3, 7):
loop = asyncio.get_event_loop()
loop.create_task(dummy_async_func())
else:
asyncio.create_task(dummy_async_func())
asyncio.create_task(dummy_async_func())

@context
def fail_top(context):
Expand Down
9 changes: 1 addition & 8 deletions tests/testcase_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import asyncio
import csv
import sys
import unittest

import testslide
Expand Down Expand Up @@ -41,13 +40,7 @@ def test_has_mock_async_callable(self):
self.mock_async_callable(SomeClass, "async_do_something").to_return_value(
42
).and_assert_called_once()
if sys.version_info >= (3, 7):
self.assertEqual(asyncio.run(SomeClass.async_do_something()), 42)
else:
loop = asyncio.get_event_loop()
result = loop.run_until_complete(SomeClass.async_do_something())
loop.close()
self.assertEqual(result, 42)
self.assertEqual(asyncio.run(SomeClass.async_do_something()), 42)

def test_has_mock_constructor(self):
dict_reader = testslide.StrictMock(csv.DictReader)
Expand Down
20 changes: 2 additions & 18 deletions testslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,11 @@
# hack for Mypy
from testslide.runner import BaseFormatter

if sys.version_info < (3, 6):
raise RuntimeError("Python >=3.6 required.")

if sys.version_info < (3, 7):
raise RuntimeError("Python >=3.7 required.")

def asyncio_run(coro):
loop = asyncio.events.new_event_loop()
try:
loop.set_debug(True)
loop.run_until_complete(coro)
finally:
try:
loop.run_until_complete(loop.shutdown_asyncgens())
finally:
loop.close()

else:
asyncio_run = partial(asyncio.run, debug=True)
asyncio_run = partial(asyncio.run, debug=True)


if sys.version_info < (3, 8):
Expand Down Expand Up @@ -400,9 +387,6 @@ async def async_wrapped() -> None:

@contextlib.contextmanager
def _raise_if_asyncio_warnings(self, context_data: _ContextData) -> Iterator[None]:
if sys.version_info < (3, 7):
yield
return
original_showwarning = warnings.showwarning
caught_failures: List[Union[Exception, str]] = []

Expand Down
2 changes: 1 addition & 1 deletion testslide/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_args(tp):
return tp.__args__
return ()

else: # python3.6
else:
from typing import GenericMeta # type: ignore

def get_origin(tp):
Expand Down

0 comments on commit 5ce7b7f

Please sign in to comment.