Skip to content

Commit

Permalink
nose is deprecated. migrate to pytest.
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Sep 13, 2023
1 parent 5af561c commit 4a00306
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements-test.txt
pip install -r requirements.txt
- name: Unit tests with nose
- name: Unit tests with pytest
run: |
nosetests
pytest rcvformats/test
- name: CLI tests
run: |
pip install .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ except Exception as e:
In addition to data normalization for RCV Summary formats, we would like similar functionality for cast vote records.

## Running test suite
`pip3 install -r requirements-test.txt`, then run `python3 -m nose` in the root directory, and `./scripts/lint.sh` to run the linter.
`pip3 install -r requirements-test.txt`, then run `pytest rcvformats/test` in the root directory, and `./scripts/lint.sh` to run the linter.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import os
import json
import nose

from rcvformats.conversions import automatic
from rcvformats.conversions import dominion_multi_converter
Expand All @@ -18,14 +17,13 @@

def _assert_conversion_correct(file_in, file_out, converter):
""" Asserts that converter.convert_to_ut(file_in) = file_out """
nose.tools.assert_dict_equal.__self__.maxDiff = None
actual_data = converter.convert_to_ut_and_validate(file_in)
with open(file_out, 'r', encoding='utf-8') as file_obj:
expected_data = json.load(file_obj)

# Ensure the file buffers aren't closed
file_obj.seek(0)
nose.tools.assert_dict_equal(actual_data, expected_data)
assert actual_data == expected_data


def _files_in_dir(input_dir):
Expand All @@ -52,7 +50,7 @@ def _assert_auto_gives_same_result_as(input_dir, direct_converter):
expected_data_without_xfer = direct_converter.convert_to_ut_and_validate(filepath)
expected_data = add_transfer_converter.fill_in_tally_data(expected_data_without_xfer)

nose.tools.assert_dict_equal(auto_data, expected_data)
assert auto_data == expected_data


def test_electionbuddy_conversions_succeed():
Expand Down Expand Up @@ -133,7 +131,7 @@ def test_automatic_conversions_universal_tabulator():
with open(filepath, 'r', encoding='utf-8') as input_file:
input_data = json.load(input_file)

nose.tools.assert_dict_equal(input_data, output_data)
assert input_data == output_data


def test_automatic_conversions_opavote10():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""
Safety tests: enforce security measures here
"""
import nose
from openpyxl import DEFUSEDXML


def test_electionbuddy_conversions_succeed():
""" Ensures defusedXml is installed to prevent malicious XML attacks """
nose.tools.assert_true(DEFUSEDXML)
assert DEFUSEDXML
File renamed without changes.
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nose-py3==1.6.2
pylint==2.17.4
pytest==7.3.2
autopep8==2.0.2

0 comments on commit 4a00306

Please sign in to comment.