Skip to content

Commit 2d74136

Browse files
authored
Move all static analisys before tests: make CI faster (#86)
* Remove useless `six` usage in tests * remove `__getitem__` access to exec_result (legacy code) * enforce black codestyle validation
1 parent d478c4f commit 2d74136

File tree

6 files changed

+33
-28
lines changed

6 files changed

+33
-28
lines changed

.travis.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,6 @@ after_success:
6464
jobs:
6565
fast_finish: true
6666
include:
67-
- stage: test
68-
<<: *python34
69-
- stage: test
70-
<<: *python35
71-
- stage: test
72-
<<: *python36
73-
- stage: test
74-
<<: *python37
75-
- stage: test
76-
<<: *pypy3
77-
7867
- <<: *static_analysis
7968
name: "PyLint"
8069
install:
@@ -99,15 +88,6 @@ jobs:
9988
script:
10089
- mypy --strict exec_helpers
10190

102-
- <<: *test_cythonized
103-
<<: *python34
104-
- <<: *test_cythonized
105-
<<: *python35
106-
- <<: *test_cythonized
107-
<<: *python36
108-
- <<: *test_cythonized
109-
<<: *python37
110-
11191
- <<: *code_style_check
11292
name: "PEP8"
11393
install:
@@ -122,6 +102,33 @@ jobs:
122102
- pip install --upgrade pydocstyle
123103
script:
124104
- pydocstyle exec_helpers
105+
- <<: *code_style_check
106+
name: "Black formatting"
107+
install:
108+
- *upgrade_python_toolset
109+
- pip install --upgrade black
110+
script:
111+
- black --check exec_helpers
112+
113+
- stage: test
114+
<<: *python34
115+
- stage: test
116+
<<: *python35
117+
- stage: test
118+
<<: *python36
119+
- stage: test
120+
<<: *python37
121+
- stage: test
122+
<<: *pypy3
123+
124+
- <<: *test_cythonized
125+
<<: *python34
126+
- <<: *test_cythonized
127+
<<: *python35
128+
- <<: *test_cythonized
129+
<<: *python36
130+
- <<: *test_cythonized
131+
<<: *python37
125132

126133
- stage: deploy
127134
# This prevents job from appearing in test plan unless commit is tagged:

exec_helpers/_ssh_client_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
logging.getLogger("iso8601").setLevel(logging.WARNING)
5050

5151

52+
# noinspection PyTypeHints
5253
class SshExecuteAsyncResult(api.ExecuteAsyncResult):
5354
"""Override original NamedTuple with proper typing."""
5455

exec_helpers/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def check_call(
293293
"""
294294
expected = proc_enums.exit_codes_to_enums(expected)
295295
ret = self.execute(command, verbose, timeout, **kwargs)
296-
if ret["exit_code"] not in expected:
296+
if ret.exit_code not in expected:
297297
message = (
298298
"{append}Command {result.cmd!r} returned exit code "
299299
"{result.exit_code!s} while expected {expected!s}".format(
@@ -338,7 +338,7 @@ def check_stderr(
338338
ret = self.check_call(
339339
command, verbose, timeout=timeout, error_info=error_info, raise_on_err=raise_on_err, **kwargs
340340
)
341-
if ret["stderr"]:
341+
if ret.stderr:
342342
message = (
343343
"{append}Command {result.cmd!r} STDERR while not expected\n"
344344
"\texit code: {result.exit_code!s}".format(append=error_info + "\n" if error_info else "", result=ret)

exec_helpers/subprocess_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
logger = logging.getLogger(__name__) # type: logging.Logger
3838

3939

40+
# noinspection PyTypeHints
4041
class SubprocessExecuteAsyncResult(api.ExecuteAsyncResult):
4142
"""Override original NamedTuple with proper typing."""
4243

test/test_sshauth.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
import base64
2626
import contextlib
2727
import copy
28+
import io
2829
import unittest
2930

3031
import mock
3132
import paramiko
32-
# noinspection PyUnresolvedReferences
33-
from six.moves import cStringIO
3433

3534
import exec_helpers
3635

@@ -114,7 +113,7 @@ def init_checks(
114113
int_keys.append(k)
115114

116115
self.assertEqual(auth.username, username)
117-
with contextlib.closing(cStringIO()) as tgt:
116+
with contextlib.closing(io.StringIO()) as tgt:
118117
auth.enter_password(tgt)
119118
self.assertEqual(tgt.getvalue(), '{}\n'.format(password))
120119
self.assertEqual(

test/test_subprocess_runner.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import unittest
2727

2828
import mock
29-
import six
3029

3130
import exec_helpers
3231
from exec_helpers import subprocess_runner
@@ -553,7 +552,6 @@ def test_006_check_stdin_bytearray(
553552
mock.call.close()
554553
])
555554

556-
@unittest.skipIf(six.PY2, 'Not implemented exception')
557555
def test_007_check_stdin_fail_broken_pipe(
558556
self,
559557
popen, # type: mock.MagicMock
@@ -657,7 +655,6 @@ def test_009_check_stdin_fail_write(
657655
runner.execute_async(print_stdin, stdin=stdin)
658656
popen_obj.kill.assert_called_once()
659657

660-
@unittest.skipIf(six.PY2, 'Not implemented exception')
661658
def test_010_check_stdin_fail_close_pipe(
662659
self,
663660
popen, # type: mock.MagicMock

0 commit comments

Comments
 (0)