Skip to content

Commit

Permalink
Merge pull request #10 from eriknovak/feature/tests
Browse files Browse the repository at this point in the history
Unit test book keeping and expanding test environment on all OS
  • Loading branch information
eriknovak committed May 29, 2024
2 parents 19c2340 + aaeab18 commit 7dfdc64
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"] # "3.11" - for some reason the models give different predictions on 3.11
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ dmypy.json

.vscode

data/*
data/**/
!data/README.md

models/**/
!models/README.md

notebooks
!docs/documentation/notebooks

Expand Down
7 changes: 7 additions & 0 deletions test/test_extractors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import warnings

from anonipy.definitions import Entity
from anonipy.anonymize.extractors import EntityExtractor
Expand Down Expand Up @@ -97,6 +98,12 @@


class TestEntityExtractor(unittest.TestCase):

def setUp(self):
warnings.filterwarnings("ignore", category=ImportWarning)
warnings.filterwarnings("ignore", category=UserWarning)
warnings.filterwarnings("ignore", category=FutureWarning)

def test_init(self):
try:
EntityExtractor()
Expand Down
6 changes: 6 additions & 0 deletions test/test_generators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import unittest
import warnings

import torch

Expand Down Expand Up @@ -124,6 +125,11 @@ class TestMaskLabelGenerator(unittest.TestCase):
def setUpClass(self):
self.generator = MaskLabelGenerator()

def setUp(self):
warnings.filterwarnings("ignore", category=ImportWarning)
warnings.filterwarnings("ignore", category=UserWarning)
warnings.filterwarnings("ignore", category=FutureWarning)

def test_has_methods(self):
self.assertEqual(hasattr(self.generator, "generate"), True)

Expand Down
6 changes: 6 additions & 0 deletions test/test_language_detector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import warnings

from anonipy.utils.language_detector import LanguageDetector
from anonipy.constants import LANGUAGES
Expand All @@ -10,6 +11,11 @@

class TestLanguageDetector(unittest.TestCase):

def setUp(self):
warnings.filterwarnings("ignore", category=ImportWarning)
warnings.filterwarnings("ignore", category=UserWarning)
warnings.filterwarnings("ignore", category=FutureWarning)

def test_init(self):
language_detector = LanguageDetector()
self.assertEqual(language_detector.__class__, LanguageDetector)
Expand Down

0 comments on commit 7dfdc64

Please sign in to comment.