Skip to content

Commit

Permalink
Require Python 3.7+ for async functionality (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Jul 19, 2020
1 parent 6c5c9fe commit 6bf4541
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Expand Up @@ -14,11 +14,11 @@ install:
- pip install .
- pip install flake8 pylint coveralls cryptography libusb1>=1.0.16 pycryptodome
- python --version 2>&1 | grep -q "Python 2" && pip install mock || true
- 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
- if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then pip install aiofiles; fi
script:
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
after_success:
- if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8"; then coveralls; fi
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -26,7 +26,7 @@ Installation
Async
*****

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

.. code-block::
Expand Down
6 changes: 1 addition & 5 deletions adb_shell/adb_device_async.py
Expand Up @@ -57,11 +57,7 @@
"""


try:
from asyncio import get_running_loop
except ImportError: # pragma: no cover
from asyncio import get_event_loop as get_running_loop # Python 3.6 compatibility

from asyncio import get_running_loop
import logging
import os
import socket
Expand Down
3 changes: 1 addition & 2 deletions tests/patchers.py
Expand Up @@ -8,8 +8,7 @@
from adb_shell.transport.tcp_transport import TcpTransport


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

MSG_CONNECT = AdbMessage(command=constants.CNXN, arg0=constants.PROTOCOL, arg1=constants.MAX_LEGACY_ADB_DATA, data=b'host::unknown\0')
MSG_CONNECT_WITH_AUTH_INVALID = AdbMessage(command=constants.AUTH, arg0=0, arg1=0, data=b'host::unknown\0')
Expand Down
14 changes: 7 additions & 7 deletions tests/test_adb_device_async.py
Expand Up @@ -553,7 +553,7 @@ async def test_list(self):
self.assertEqual(await self.device.list('/dir'), expected_result)
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)

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

@patchers.ASYNC_SKIPPER37
@patchers.ASYNC_SKIPPER
@awaiter
async def test_push_file(self):
self.assertTrue(await self.device.connect())
Expand All @@ -597,7 +597,7 @@ async def test_push_file(self):
await self.device.push('TEST_FILE', '/data', mtime=mtime)
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)

@patchers.ASYNC_SKIPPER37
@patchers.ASYNC_SKIPPER
@awaiter
async def test_push_file_mtime0(self):
self.assertTrue(await self.device.connect())
Expand All @@ -624,7 +624,7 @@ async def test_push_file_mtime0(self):
await self.device.push('TEST_FILE', '/data', mtime=mtime)
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)

@patchers.ASYNC_SKIPPER37
@patchers.ASYNC_SKIPPER
@awaiter
async def test_push_big_file(self):
self.assertTrue(await self.device.connect())
Expand Down Expand Up @@ -660,7 +660,7 @@ async def test_push_big_file(self):
await self.device.push('TEST_FILE', '/data', mtime=mtime)
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)

@patchers.ASYNC_SKIPPER37
@patchers.ASYNC_SKIPPER
@awaiter
async def test_push_dir(self):
self.assertTrue(await self.device.connect())
Expand All @@ -686,7 +686,7 @@ async def test_push_dir(self):
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']):
await self.device.push('TEST_DIR/', '/data', mtime=mtime)

@patchers.ASYNC_SKIPPER37
@patchers.ASYNC_SKIPPER
@awaiter
async def test_pull_file(self):
self.assertTrue(await self.device.connect())
Expand All @@ -712,7 +712,7 @@ async def test_pull_file(self):
self.assertEqual(m.written, filedata)
self.assertEqual(self.device._transport._bulk_write, expected_bulk_write)

@patchers.ASYNC_SKIPPER37
@patchers.ASYNC_SKIPPER
@awaiter
async def test_pull_big_file(self):
self.assertTrue(await self.device.connect())
Expand Down

0 comments on commit 6bf4541

Please sign in to comment.