Skip to content

Commit

Permalink
Merge pull request kytos#22 from kytos-ng/chore/tox_py39_x
Browse files Browse the repository at this point in the history
Updated tox.ini and removed `tests_require` and `setup_requires`
  • Loading branch information
viniarck authored Jun 14, 2022
2 parents ed59481 + 9594cc9 commit 61cfcde
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[run]
source = .
omit = .eggs/*,.tox/*,*tests*,setup.py,venv/*
omit = .eggs/*,.tox/*,*tests*,setup.py,venv/*,.venv/*,.direnv/*
55 changes: 48 additions & 7 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --output-file=requirements/dev.txt requirements/dev.in
Expand All @@ -14,17 +14,27 @@
# kytos
astroid==2.9.3
# via pylint
attrs==21.4.0
# via pytest
backcall==0.1.0
# via
# ipython
# kytos
blinker==1.4
# via
# elastic-apm
# kytos
certifi==2021.10.8
# via
# elastic-apm
# kytos
click==8.0.3
# via
# flask
# kytos
# pip-tools
coverage==6.2
# via kytos-pathfinder
coverage[toml]==6.2
# via pytest-cov
decorator==4.4.2
# via
# ipython
Expand All @@ -40,6 +50,8 @@ docutils==0.18.1
# via
# kytos
# python-daemon
elastic-apm[flask]==6.9.1
# via kytos
filelock==3.4.1
# via
# tox
Expand All @@ -53,6 +65,8 @@ flask-cors==3.0.8
# via kytos
flask-socketio==4.2.1
# via kytos
iniconfig==1.1.1
# via pytest
ipython==7.13.0
# via kytos
ipython-genutils==0.2.0
Expand Down Expand Up @@ -92,7 +106,9 @@ mccabe==0.6.1
networkx==2.5.1
# via kytos-pathfinder
packaging==21.3
# via tox
# via
# pytest
# tox
parso==0.6.2
# via
# jedi
Expand All @@ -118,7 +134,9 @@ platformdirs==2.4.0
# pylint
# virtualenv
pluggy==1.0.0
# via tox
# via
# pytest
# tox
prompt-toolkit==3.0.5
# via
# ipython
Expand All @@ -128,9 +146,13 @@ ptyprocess==0.6.0
# kytos
# pexpect
py==1.11.0
# via tox
# via
# pytest
# tox
pycodestyle==2.8.0
# via yala
pydantic==1.9.0
# via kytos
pygments==2.11.2
# via
# ipython
Expand All @@ -139,8 +161,16 @@ pyjwt==1.7.1
# via kytos
pylint==2.12.2
# via yala
pymongo==4.1.0
# via kytos
pyparsing==3.0.6
# via packaging
pytest==7.0.0
# via
# kytos-pathfinder
# pytest-cov
pytest-cov==3.0.0
# via kytos-pathfinder
python-daemon==2.2.4
# via kytos
python-engineio==3.12.1
Expand All @@ -160,12 +190,17 @@ six==1.16.0
# tox
# traitlets
# virtualenv
tenacity==8.0.1
# via kytos
toml==0.10.2
# via
# pylint
# tox
tomli==1.2.3
# via pep517
# via
# coverage
# pep517
# pytest
tox==3.24.5
# via kytos-pathfinder
traitlets==4.3.3
Expand All @@ -175,7 +210,13 @@ traitlets==4.3.3
typing-extensions==4.0.1
# via
# astroid
# kytos
# pydantic
# pylint
urllib3==1.26.7
# via
# elastic-apm
# kytos
virtualenv==20.13.0
# via tox
watchdog==0.10.2
Expand Down
8 changes: 1 addition & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ max-line-length = 88

[yala]
radon mi args = --min C
pylint args = --disable=too-few-public-methods,too-many-instance-attributes,super-init-not-called,too-many-branches,attribute-defined-outside-init,raise-missing-from,no-name-in-module,wrong-import-order
pylint args = --disable=too-few-public-methods,too-many-instance-attributes,super-init-not-called,too-many-branches,attribute-defined-outside-init,raise-missing-from,no-name-in-module,wrong-import-order,unnecessary-pass,
linters=pylint,pycodestyle,isort

[pydocstyle]
Expand All @@ -19,9 +19,3 @@ known_first_party = kytos.napps,tests
known_third_party = pyof,kytos
# Ignoring tests because is adding napps path
skip=tests

[tool:pytest]
markers =
small: marks tests as small
medium: marks tests as medium
large: marks tests as large
55 changes: 10 additions & 45 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,22 @@ class TestCommand(Command):
"""Test tags decorators."""

user_options = [
('size=', None, 'Specify the size of tests to be executed.'),
('type=', None, 'Specify the type of tests to be executed.'),
('k=', None, 'Specify a pytest -k expression.'),
]

sizes = ('small', 'medium', 'large', 'all')
types = ('unit', 'integration', 'e2e', 'all')

def get_args(self):
"""Return args to be used in test command."""
return '--size %s --type %s' % (self.size, self.type)
if self.k:
return f"-k '{self.k}'"
return ""

def initialize_options(self):
"""Set default size and type args."""
self.size = 'all'
self.type = 'all'
self.k = ""

def finalize_options(self):
"""Post-process."""
try:
assert self.size in self.sizes, ('ERROR: Invalid size:'
f':{self.size}')
assert self.type in self.types, ('ERROR: Invalid type:'
f':{self.type}')
except AssertionError as exc:
print(exc)
sys.exit(-1)
pass


class Cleaner(SimpleCommand):
Expand All @@ -114,18 +104,9 @@ class Test(TestCommand):

description = 'run tests and display results'

def get_args(self):
"""Return args to be used in test command."""
markers = self.size
if markers == "small":
markers = 'not medium and not large'
size_args = "" if self.size == "all" else "-m '%s'" % markers
test_type = "" if self.type == "all" else self.type
return '--addopts="tests/%s %s"' % (test_type, size_args)

def run(self):
"""Run tests."""
cmd = 'python setup.py pytest %s' % self.get_args()
cmd = 'python3 -m pytest tests/ %s' % self.get_args()
try:
check_call(cmd, shell=True)
except CalledProcessError as exc:
Expand All @@ -141,8 +122,7 @@ class TestCoverage(Test):

def run(self):
"""Run tests quietly and display coverage report."""
cmd = 'coverage3 run setup.py pytest %s' % self.get_args()
cmd += '&& coverage3 report'
cmd = 'python3 -m pytest --cov=. tests/ %s' % self.get_args()
try:
check_call(cmd, shell=True)
except CalledProcessError as exc:
Expand All @@ -168,19 +148,6 @@ def run(self):
exit(-1)


class CITest(TestCommand):
"""Run all CI tests."""

description = 'run all CI tests: unit and doc tests, linter'

def run(self):
"""Run unit tests with coverage, doc tests and linter."""
coverage_cmd = 'python3 setup.py coverage %s' % self.get_args()
lint_cmd = 'python3 setup.py lint'
cmd = '%s && %s' % (coverage_cmd, lint_cmd)
check_call(cmd, shell=True)


class KytosInstall:
"""Common code for all install types."""

Expand Down Expand Up @@ -296,19 +263,17 @@ def read_requirements(path="requirements/run.txt"):
author_email='[email protected]',
license='MIT',
install_requires=read_requirements(),
setup_requires=['pytest-runner'],
tests_require=['pytest==7.0.0'],
extras_require={
'dev': [
'coverage',
'pytest==7.0.0',
'pytest-cov==3.0.0',
'pip-tools',
'yala',
'tox',
],
},
cmdclass={
'clean': Cleaner,
'ci': CITest,
'coverage': TestCoverage,
'develop': DevelopMode,
'install': InstallMode,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_paths_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_path_s1_s4(self):
"""Tests a simple, impossible path"""
self.initializer()

assert self.graph.constrained_k_shortest_paths("S1", "S4") == []
assert not self.graph.constrained_k_shortest_paths("S1", "S4")

def test_path_to_self(self):
"""Tests a path to self again"""
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ def test_update_links_not_up(self):
self.kytos_graph.update_links(topology.links)
assert self.mock_graph.add_edge.call_count == len(topology.links) - keys_num

# pylint: disable=consider-using-dict-items
def test_update_nodes_not_up(self):
"""Test update_nodes entity not up."""
topology = get_topology_mock()
keys_num = 2
for key in list(topology.switches.keys())[:keys_num]:
for key in list(topology.switches)[:keys_num]:
topology.switches[key].status = EntityStatus.DISABLED
for key in topology.switches.keys():
for key in topology.switches:
topology.switches[key].interfaces = {}

self.kytos_graph.update_nodes(topology.switches)
Expand Down
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ setenv=
skip_install = true
envdir = {toxworkdir}/py39
commands=
; Force packaging even if setup.{py,cfg} haven't changed
rm -rf ./*.egg-info/
python setup.py coverage
python3 setup.py coverage {posargs}


[testenv:lint]
skip_install = true
envdir = {toxworkdir}/py39
commands = python setup.py lint
commands = python3 setup.py lint

0 comments on commit 61cfcde

Please sign in to comment.