Skip to content

Commit

Permalink
Switch from nose to vanilla unittest (anhaidgroup#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
zware committed Jan 2, 2023
1 parent 1c3571b commit e943595
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 20 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ omit =
*/benchmarks/*
*__init__*
*/python?.?/*
*/site-packages/nose/*
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ htmlcov/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ install:
- conda create --yes -n py_stringmatching_test_env python=$PYTHON_VERSION
- source activate py_stringmatching_test_env
- python --version
- pip install numpy six nose Cython>=0.29.23 coveralls
- pip install numpy six Cython>=0.29.23 coveralls
- python setup.py build_ext --inplace

script:
- coverage run -m nose
- coverage run -m unittest
- uname -a

after_success:
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ install:
- python -m pip install --upgrade pip

# Install the build and runtime dependencies of the project.
- pip install setuptools numpy six nose cython>=0.29.23 wheel
- pip install setuptools numpy six cython>=0.29.23 wheel

# Build the project
- python setup.py build_ext --inplace

build: false

test_script:
# Nosetests take care of unit tests
- nosetests
# unittest discovery finds the tests for us
- python -m unittest

after_test:
- ver
Expand Down
1 change: 0 additions & 1 deletion build_tools/requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
numpy>=1.7.0
six
Cython
nose
8 changes: 4 additions & 4 deletions docs/Contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ nor any existing python installation. It will install all of the basic dependenc
*py_stringmatching*, as well as the development and testing tools. If you would like to install
other dependencies, you can install them as follows::

conda install -n py_stringmatching_dev nose
conda install -n py_stringmatching_dev numpy

.. To install *all* py_stringmatching dependencies you can do the following::
Expand Down Expand Up @@ -347,8 +347,8 @@ it is worth getting in the habit of writing tests ahead of time so this is never

Unit testing
~~~~~~~~~~~~~
Like many packages, *py_stringmatching* uses the `Nose testing system
<http://nose.readthedocs.org/en/latest/index.html>`_.
Like many packages, *py_stringmatching* uses the `standard ``unittest``
testing library <https://docs.python.org/3/library/unittest.html>`_.

All tests should go into the ``tests`` subdirectory of the specific package.
This folder contains many current examples of tests, and we suggest looking to these for
Expand All @@ -357,7 +357,7 @@ inspiration.
The tests can then be run directly inside your Git clone (without having to
install *py_stringmatching*) by typing::

nosetests
python3 -m unittest


Performance testing
Expand Down
7 changes: 4 additions & 3 deletions py_stringmatching/tests/test_sim_Soundex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import math
import unittest

from nose.tools import *

from py_stringmatching.similarity_measure.soundex import Soundex

from .utils import raises


class SoundexTestCases(unittest.TestCase):
def setUp(self):
self.sdx = Soundex()
Expand Down Expand Up @@ -102,4 +103,4 @@ def test_invalid_input10_sim_score(self):

@raises(TypeError)
def test_invalid_input11_sim_score(self):
self.sdx.get_sim_score('abc', 123)
self.sdx.get_sim_score('abc', 123)
5 changes: 1 addition & 4 deletions py_stringmatching/tests/test_simfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import math
import unittest

from nose.tools import *



from .utils import raises

# sequence based similarity measures
from py_stringmatching.similarity_measure.affine import Affine
Expand Down
3 changes: 2 additions & 1 deletion py_stringmatching/tests/test_tokenizers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import unicode_literals

import unittest
from nose.tools import *

from py_stringmatching.tokenizer.alphabetic_tokenizer import AlphabeticTokenizer
from py_stringmatching.tokenizer.alphanumeric_tokenizer import AlphanumericTokenizer
from py_stringmatching.tokenizer.delimiter_tokenizer import DelimiterTokenizer
from py_stringmatching.tokenizer.qgram_tokenizer import QgramTokenizer
from py_stringmatching.tokenizer.whitespace_tokenizer import WhitespaceTokenizer

from .utils import raises


class QgramTokenizerTestCases(unittest.TestCase):
def setUp(self):
Expand Down
8 changes: 8 additions & 0 deletions py_stringmatching/tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Simplified knockoff of nose.tools.raises
def raises(exc_type):
def deco(f):
def raises_wrapper(self):
with self.assertRaises(exc_type):
return f(self)
return raises_wrapper
return deco

0 comments on commit e943595

Please sign in to comment.