diff --git a/tests/test_approval.py b/tests/test_approval.py index 2b07573..1c6a070 100644 --- a/tests/test_approval.py +++ b/tests/test_approval.py @@ -1,9 +1,11 @@ import random + import numpy as np import pytest from hypothesis import given -from hypothesis.strategies import integers, tuples from hypothesis.extra.numpy import arrays +from hypothesis.strategies import integers, tuples + from elsim.methods import approval, combined_approval @@ -182,7 +184,7 @@ def test_invalid(method): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_black.py b/tests/test_black.py index 7880afa..3288128 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2,6 +2,7 @@ import pytest from hypothesis import given from hypothesis.strategies import integers, lists, permutations + from elsim.methods import black @@ -152,7 +153,7 @@ def test_legit_winner_none(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_borda.py b/tests/test_borda.py index 75a3ed8..15b699d 100644 --- a/tests/test_borda.py +++ b/tests/test_borda.py @@ -1,8 +1,10 @@ import random + import numpy as np import pytest from hypothesis import given from hypothesis.strategies import integers, lists, permutations + from elsim.methods import borda @@ -184,7 +186,7 @@ def test_legit_winner_none(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_condorcet.py b/tests/test_condorcet.py index e567296..3e75d38 100644 --- a/tests/test_condorcet.py +++ b/tests/test_condorcet.py @@ -1,8 +1,9 @@ import numpy as np -from numpy.testing import assert_array_equal import pytest from hypothesis import given from hypothesis.strategies import integers, lists, permutations +from numpy.testing import assert_array_equal + from elsim.methods import (condorcet, condorcet_from_matrix, ranked_election_to_matrix) @@ -304,7 +305,7 @@ def test_ranked_election_to_matrix(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_coombs.py b/tests/test_coombs.py index 7ab66a8..3d5a41a 100644 --- a/tests/test_coombs.py +++ b/tests/test_coombs.py @@ -1,8 +1,10 @@ import random + import numpy as np import pytest -from hypothesis.strategies import integers, permutations, lists from hypothesis import given +from hypothesis.strategies import integers, lists, permutations + from elsim.methods import coombs @@ -219,7 +221,7 @@ def test_legit_winner_none(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_elections.py b/tests/test_elections.py index 7a99d6b..b831fa7 100644 --- a/tests/test_elections.py +++ b/tests/test_elections.py @@ -1,9 +1,10 @@ import numpy as np -from numpy.testing import (assert_array_equal, assert_array_less, - assert_allclose) import pytest -from elsim.elections import (random_utilities, impartial_culture, - normal_electorate, normed_dist_utilities) +from numpy.testing import (assert_allclose, assert_array_equal, + assert_array_less) + +from elsim.elections import (impartial_culture, normal_electorate, + normed_dist_utilities, random_utilities) def test_random_utilities(): @@ -134,7 +135,7 @@ def test_invalid_random_state(func): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_fptp.py b/tests/test_fptp.py index 2eda984..ea801c6 100644 --- a/tests/test_fptp.py +++ b/tests/test_fptp.py @@ -1,8 +1,10 @@ import random + import numpy as np import pytest from hypothesis import given from hypothesis.strategies import integers, lists, permutations + from elsim.methods import fptp @@ -222,7 +224,7 @@ def test_legit_winner_none_single_mark(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_irv.py b/tests/test_irv.py index dc27e56..727a7be 100644 --- a/tests/test_irv.py +++ b/tests/test_irv.py @@ -2,8 +2,8 @@ import numpy as np import pytest -from hypothesis.strategies import integers, permutations, lists from hypothesis import given +from hypothesis.strategies import integers, lists, permutations from elsim.methods import irv @@ -285,7 +285,7 @@ def test_legit_winner_none(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_methods.py b/tests/test_methods.py index 91bf945..d568e85 100644 --- a/tests/test_methods.py +++ b/tests/test_methods.py @@ -1,6 +1,7 @@ import pytest -from elsim.methods import (black, borda, fptp, runoff, irv, coombs, approval, - combined_approval, utility_winner, score) + +from elsim.methods import (approval, black, borda, combined_approval, coombs, + fptp, irv, runoff, score, utility_winner) @pytest.mark.parametrize("method", [black, borda, fptp, runoff, irv, coombs, @@ -37,7 +38,7 @@ def test_ranked_method_unanimity(method): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_runoff.py b/tests/test_runoff.py index 378061d..09b57de 100644 --- a/tests/test_runoff.py +++ b/tests/test_runoff.py @@ -2,8 +2,8 @@ import numpy as np import pytest -from hypothesis.strategies import integers, permutations, lists from hypothesis import given +from hypothesis.strategies import integers, lists, permutations from elsim.methods import runoff @@ -202,7 +202,7 @@ def test_legit_winner_none(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_score.py b/tests/test_score.py index 3bfaaa8..959a227 100644 --- a/tests/test_score.py +++ b/tests/test_score.py @@ -1,9 +1,11 @@ import random + import numpy as np import pytest from hypothesis import given -from hypothesis.strategies import integers, tuples from hypothesis.extra.numpy import arrays +from hypothesis.strategies import integers, tuples + from elsim.methods import score @@ -169,7 +171,7 @@ def test_invalid(method): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_sntv.py b/tests/test_sntv.py index f290254..7f603bf 100644 --- a/tests/test_sntv.py +++ b/tests/test_sntv.py @@ -1,8 +1,10 @@ import random + import numpy as np import pytest from hypothesis import given from hypothesis.strategies import integers, lists, permutations + from elsim.methods import sntv @@ -292,7 +294,7 @@ def test_defaults(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_star.py b/tests/test_star.py index 675d734..79b5fae 100644 --- a/tests/test_star.py +++ b/tests/test_star.py @@ -1,10 +1,13 @@ import random + import numpy as np -from numpy.testing import assert_array_equal import pytest -from hypothesis import given -from elsim.methods import star, matrix_from_scores import test_score +from hypothesis import given +from numpy.testing import assert_array_equal + +from elsim.methods import matrix_from_scores, star + score_ballots = test_score.score_ballots @@ -630,7 +633,7 @@ def test_matrix_from_scores_properties(election, method): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_strategies.py b/tests/test_strategies.py index 3db92a2..730c7d0 100644 --- a/tests/test_strategies.py +++ b/tests/test_strategies.py @@ -1,11 +1,11 @@ import numpy as np -from numpy.testing import assert_array_equal import pytest from hypothesis import given -from hypothesis.strategies import integers, tuples, floats from hypothesis.extra.numpy import arrays -from elsim.strategies import (approval_optimal, vote_for_k, - honest_normed_scores) +from hypothesis.strategies import floats, integers, tuples +from numpy.testing import assert_array_equal + +from elsim.strategies import approval_optimal, honest_normed_scores, vote_for_k def test_approval_optimal(): @@ -114,7 +114,7 @@ def test_honest_normed_scores_properties(utilities, max_score): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics', diff --git a/tests/test_utility_winner.py b/tests/test_utility_winner.py index 8285462..440d340 100644 --- a/tests/test_utility_winner.py +++ b/tests/test_utility_winner.py @@ -1,9 +1,11 @@ import random + import numpy as np import pytest from hypothesis import given -from hypothesis.strategies import integers, tuples, floats from hypothesis.extra.numpy import arrays +from hypothesis.strategies import floats, integers, tuples + from elsim.methods import utility_winner @@ -101,7 +103,7 @@ def test_legit_winner_no_tiebreaker(election): if __name__ == "__main__": # Run unit tests, in separate process to avoid warnings about cached # modules, printing output line by line in realtime - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen with Popen(['pytest', '--tb=short', # shorter traceback format '--hypothesis-show-statistics',