Skip to content

Commit 6bf4541

Browse files
authored
Require Python 3.7+ for async functionality (#113)
1 parent 6c5c9fe commit 6bf4541

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ install:
1414
- pip install .
1515
- pip install flake8 pylint coveralls cryptography libusb1>=1.0.16 pycryptodome
1616
- python --version 2>&1 | grep -q "Python 2" && pip install mock || true
17-
- if python --version 2>&1 | grep -q "Python 3.6" || python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then pip install aiofiles; fi
17+
- if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then pip install aiofiles; fi
1818
script:
19-
- if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5"; then flake8 adb_shell/ --exclude="adb_shell/adb_device_async.py,adb_shell/transport/base_transport_async.py,adb_shell/transport/tcp_transport_async.py" && pylint --ignore="adb_device_async.py,base_transport_async.py,tcp_transport_async.py" adb_shell/; fi
20-
- if python --version 2>&1 | grep -q "Python 3.6" || python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then flake8 adb_shell/ && pylint adb_shell/; fi
21-
- if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5"; then for synctest in $(cd tests && ls test*.py | grep -v async); do python -m unittest discover -s tests/ -t . -p "$synctest" || exit 1; done; fi
22-
- if python --version 2>&1 | grep -q "Python 3.6" || python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then coverage run --source adb_shell -m unittest discover -s tests/ -t . && coverage report -m; fi
19+
- if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5" || python --version 2>&1 | grep -q "Python 3.6"; then flake8 adb_shell/ --exclude="adb_shell/adb_device_async.py,adb_shell/transport/base_transport_async.py,adb_shell/transport/tcp_transport_async.py" && pylint --ignore="adb_device_async.py,base_transport_async.py,tcp_transport_async.py" adb_shell/; fi
20+
- if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then flake8 adb_shell/ && pylint adb_shell/; fi
21+
- if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5" || python --version 2>&1 | grep -q "Python 3.6"; then for synctest in $(cd tests && ls test*.py | grep -v async); do python -m unittest discover -s tests/ -t . -p "$synctest" || exit 1; done; fi
22+
- if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then coverage run --source adb_shell -m unittest discover -s tests/ -t . && coverage report -m; fi
2323
after_success:
2424
- if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then coveralls; fi

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Installation
2626
Async
2727
*****
2828

29-
To utilize the async version of this code, you must install into a Python 3.6+ environment via:
29+
To utilize the async version of this code, you must install into a Python 3.7+ environment via:
3030

3131
.. code-block::
3232

adb_shell/adb_device_async.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@
5757
"""
5858

5959

60-
try:
61-
from asyncio import get_running_loop
62-
except ImportError: # pragma: no cover
63-
from asyncio import get_event_loop as get_running_loop # Python 3.6 compatibility
64-
60+
from asyncio import get_running_loop
6561
import logging
6662
import os
6763
import socket

tests/patchers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from adb_shell.transport.tcp_transport import TcpTransport
99

1010

11-
ASYNC_SKIPPER=unittest.skipIf(sys.version_info.major < 3 or sys.version_info.minor < 6, "Async functionality requires Python 3.6+")
12-
ASYNC_SKIPPER37=unittest.skipIf(sys.version_info.major < 3 or sys.version_info.minor < 7, "Async functionality requires Python 3.6+")
11+
ASYNC_SKIPPER=unittest.skipIf(sys.version_info.major < 3 or sys.version_info.minor < 7, "Async functionality requires Python 3.7+")
1312

1413
MSG_CONNECT = AdbMessage(command=constants.CNXN, arg0=constants.PROTOCOL, arg1=constants.MAX_LEGACY_ADB_DATA, data=b'host::unknown\0')
1514
MSG_CONNECT_WITH_AUTH_INVALID = AdbMessage(command=constants.AUTH, arg0=0, arg1=0, data=b'host::unknown\0')

tests/test_adb_device_async.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ async def test_list(self):
553553
self.assertEqual(await self.device.list('/dir'), expected_result)
554554
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)
555555

556-
@patchers.ASYNC_SKIPPER37
556+
@patchers.ASYNC_SKIPPER
557557
@awaiter
558558
async def test_push_fail(self):
559559
self.assertTrue(await self.device.connect())
@@ -570,7 +570,7 @@ async def test_push_fail(self):
570570
with self.assertRaises(exceptions.PushFailedError), patch('aiofiles.open', async_mock_open(read_data=filedata)):
571571
await self.device.push('TEST_FILE', '/data', mtime=mtime)
572572

573-
@patchers.ASYNC_SKIPPER37
573+
@patchers.ASYNC_SKIPPER
574574
@awaiter
575575
async def test_push_file(self):
576576
self.assertTrue(await self.device.connect())
@@ -597,7 +597,7 @@ async def test_push_file(self):
597597
await self.device.push('TEST_FILE', '/data', mtime=mtime)
598598
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)
599599

600-
@patchers.ASYNC_SKIPPER37
600+
@patchers.ASYNC_SKIPPER
601601
@awaiter
602602
async def test_push_file_mtime0(self):
603603
self.assertTrue(await self.device.connect())
@@ -624,7 +624,7 @@ async def test_push_file_mtime0(self):
624624
await self.device.push('TEST_FILE', '/data', mtime=mtime)
625625
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)
626626

627-
@patchers.ASYNC_SKIPPER37
627+
@patchers.ASYNC_SKIPPER
628628
@awaiter
629629
async def test_push_big_file(self):
630630
self.assertTrue(await self.device.connect())
@@ -660,7 +660,7 @@ async def test_push_big_file(self):
660660
await self.device.push('TEST_FILE', '/data', mtime=mtime)
661661
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)
662662

663-
@patchers.ASYNC_SKIPPER37
663+
@patchers.ASYNC_SKIPPER
664664
@awaiter
665665
async def test_push_dir(self):
666666
self.assertTrue(await self.device.connect())
@@ -686,7 +686,7 @@ async def test_push_dir(self):
686686
with patch('aiofiles.open', async_mock_open(read_data=filedata)), patch('os.path.isdir', lambda x: x == 'TEST_DIR/'), patch('os.listdir', return_value=['TEST_FILE1', 'TEST_FILE2']):
687687
await self.device.push('TEST_DIR/', '/data', mtime=mtime)
688688

689-
@patchers.ASYNC_SKIPPER37
689+
@patchers.ASYNC_SKIPPER
690690
@awaiter
691691
async def test_pull_file(self):
692692
self.assertTrue(await self.device.connect())
@@ -712,7 +712,7 @@ async def test_pull_file(self):
712712
self.assertEqual(m.written, filedata)
713713
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)
714714

715-
@patchers.ASYNC_SKIPPER37
715+
@patchers.ASYNC_SKIPPER
716716
@awaiter
717717
async def test_pull_big_file(self):
718718
self.assertTrue(await self.device.connect())

0 commit comments

Comments
 (0)