Skip to content

Commit

Permalink
Unit testing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerkin committed Feb 5, 2020
1 parent 98f17ad commit 9a9eb82
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion sciunit/unit_test/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
import unittest
from . import * # Import all the tests from the unit_test module
from .active import * # Import all the tests from the unit_test.active module

def main():
buffer = 'buffer' in sys.argv
Expand Down
4 changes: 1 addition & 3 deletions sciunit/unit_test/active.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
All active unit tests for SciUnit. This module is the default target of
for testing in `test.sh`. Modify this file if you want to add or remove
for testing in `__main__.py`. Modify this file if you want to add or remove
tests located in other modules.
"""

import unittest

from .backend_tests import *
from .command_line_tests import *
from .config_tests import *
Expand Down
14 changes: 10 additions & 4 deletions sciunit/unit_test/base.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
"""Abstract base class from some SciUnit unit test cases"""
"""Common imports for many unit tests in this directory"""

from sciunit import TestSuite
from sciunit.tests import RangeTest
from sciunit.models.examples import UniformModel
import matplotlib as mpl
import sys
import unittest

OSX = sys.platform == 'darwin'
if OSX or 'Qt' in mpl.rcParams['backend']:
mpl.use('Agg') # Avoid any problems with Macs or headless displays.

class SuiteBase(object):
"""Abstract base class for testing suites and scores"""

def setUp(self):
from sciunit.models.examples import UniformModel
from sciunit.tests import RangeTest
self.M = UniformModel
self.T = RangeTest

def prep_models_and_tests(self):
from sciunit import TestSuite
t1 = self.T([2, 3], name='test1')
t2 = self.T([5, 6])
m1 = self.M(2, 3)
Expand Down
2 changes: 1 addition & 1 deletion sciunit/unit_test/test_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sciunit.scores import FloatScore
from sciunit.capabilities import ProducesNumber

from sciunit.unit_test.base import SuiteBase
from .base import SuiteBase

class TestsTestCase(unittest.TestCase):
"""Unit tests for the sciunit module"""
Expand Down
6 changes: 2 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ pip install coveralls
if [ ! -d "../scidash" ]; then
git clone -b cosmosuite http://github.com/scidash/scidash ../scidash
fi
UNIT_TEST_SUITE="sciunit.unit_test.active buffer"
# Fundamental Python bug prevents this latter method from allowing
# some notebook tests to pass.
#UNIT_TEST_SUITE="setup.py test"
# All tests listed in sciunit/unit_test/active.py will be run
UNIT_TEST_SUITE="sciunit.unit_test buffer"
coverage run -m --source=. --omit=*unit_test*,setup.py,.eggs $UNIT_TEST_SUITE

0 comments on commit 9a9eb82

Please sign in to comment.