Permalink
Browse files

Add run_tests.py and Makefile rule to run unit test discovery with co…

…verage via Hython.

Test cleanup, no longer run coverage in each file.
  • Loading branch information...
captainhammy committed Nov 22, 2018
1 parent 8c4a204 commit c3f77d10d29d51ad3f35d5d42505958e04accb12
@@ -0,0 +1,42 @@
# .coveragerc to control coverage.py
[run]
branch = True
source =
ht.inline
ht.pyfilter.manager
ht.pyfilter.property
ht.pyfilter.utils
ht.pyfilter.operations.deepimage
ht.pyfilter.operations.ipoverrides
ht.pyfilter.operations.operation
ht.pyfilter.operations.primaryimage
ht.pyfilter.operations.zdepth
ht.sohohooks.aovs.aov
ht.sohohooks.aovs.manager
omit =
*tests*
*__init__*
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about missing debug-only code:
def __repr__
if self\.debug
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
ignore_errors = True
[html]
directory = coverage_html_report
@@ -27,3 +27,6 @@ $(CLOBBERDIRS):
.PHONY: subdirs $(CLOBBERDIRS)
.PHONY: install clean clobber
run-tests:
hython bin/run_tests.py
@@ -0,0 +1,21 @@
"""Discover and run unittests, with coverage."""
import coverage
import unittest
# Start the coverage reporting.
cov = coverage.Coverage()
cov.start()
# Find and run tests
loader = unittest.TestLoader()
suite = loader.discover(".")
runner = unittest.TextTestRunner()
runner.run(suite)
# Stop the coverage operation, generate reports.
cov.stop()
cov.save()
cov.html_report()
cov.xml_report()
@@ -456,3 +456,4 @@ def set_mantra_command(node):
cmd = "mantra `pythonexprs(\"__import__('ht.pyfilter.operations', globals(), locals(), ['ipoverrides']).ipoverrides.build_pyfilter_command_from_node(hou.pwd())\")`"
node.parm("soho_pipecmd").set(cmd)
@@ -566,7 +566,6 @@ def __init__(self, name):
# EXCEPTIONS
# =============================================================================
class AOVError(Exception): # pragma: no cover
"""AOV exception base class."""
pass
@@ -4,22 +4,15 @@
# IMPORTS
# =============================================================================
# Standard Library Imports
# Python Imports
import argparse
import coverage
from mock import MagicMock, patch
import unittest
# Houdini Toolbox Imports
from ht.pyfilter.manager import PyFilterManager
from ht.pyfilter.operations import deepimage
# Houdini Imports
import hou
cov = coverage.coverage(data_suffix=True, source=["ht.pyfilter.operations.deepimage"], branch=True)
cov.start()
reload(deepimage)
# =============================================================================
@@ -717,10 +710,4 @@ def test_should_run(self):
# =============================================================================
if __name__ == '__main__':
# Run the tests.
try:
unittest.main()
finally:
cov.stop()
cov.html_report()
cov.save()
unittest.main()
@@ -4,22 +4,18 @@
# IMPORTS
# =============================================================================
# Standard Library Imports
# Python Imports
import argparse
import coverage
from mock import MagicMock, call, patch
import unittest
# Houdini Toolbox Imports
from ht.pyfilter.operations import ipoverrides
from ht.pyfilter.manager import PyFilterManager
from ht.pyfilter.operations import ipoverrides
# Houdini Imports
import hou
cov = coverage.coverage(data_suffix=True, source=["ht.pyfilter.operations.ipoverrides"], branch=True)
cov.start()
reload(ipoverrides)
# =============================================================================
@@ -31,7 +27,7 @@ class Test_IpOverrides(unittest.TestCase):
class.
"""
def setUp(self):
super(Test_IpOverrides, self).setUp()
@@ -63,7 +59,7 @@ def test___init__(self):
# Properties
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__bucket_size(self):
def test_bucket_size(self):
op = ipoverrides.IpOverrides(None)
op._bucket_size = 16
self.assertEqual(op.bucket_size, 16)
@@ -74,7 +70,7 @@ def test_property__bucket_size(self):
self.assertEqual(op._bucket_size, 16)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__disable_aovs(self):
def test_disable_aovs(self):
op = ipoverrides.IpOverrides(None)
op._disable_aovs = True
self.assertTrue(op.disable_aovs)
@@ -85,7 +81,7 @@ def test_property__disable_aovs(self):
self.assertTrue(op._disable_aovs)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__disable_blur(self):
def test_disable_blur(self):
op = ipoverrides.IpOverrides(None)
op._disable_blur = True
self.assertTrue(op.disable_blur)
@@ -96,7 +92,7 @@ def test_property__disable_blur(self):
self.assertTrue(op._disable_blur)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__disable_deep(self):
def test_disable_deep(self):
op = ipoverrides.IpOverrides(None)
op._disable_deep = True
self.assertTrue(op.disable_deep)
@@ -107,7 +103,7 @@ def test_property__disable_deep(self):
self.assertTrue(op._disable_deep)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__disable_displacement(self):
def test_disable_displacement(self):
op = ipoverrides.IpOverrides(None)
op._disable_displacement = True
self.assertTrue(op.disable_displacement)
@@ -118,7 +114,7 @@ def test_property__disable_displacement(self):
self.assertTrue(op._disable_displacement)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__disable_matte(self):
def test_disable_matte(self):
op = ipoverrides.IpOverrides(None)
op._disable_matte = True
self.assertTrue(op.disable_matte)
@@ -129,7 +125,7 @@ def test_property__disable_matte(self):
self.assertTrue(op._disable_matte)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__disable_subd(self):
def test_disable_subd(self):
op = ipoverrides.IpOverrides(None)
op._disable_subd = True
self.assertTrue(op.disable_subd)
@@ -140,7 +136,7 @@ def test_property__disable_subd(self):
self.assertTrue(op._disable_subd)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__res_scale(self):
def test_res_scale(self):
op = ipoverrides.IpOverrides(None)
op._res_scale = 0.5
self.assertEqual(op.res_scale, 0.5)
@@ -151,7 +147,7 @@ def test_property__res_scale(self):
self.assertEqual(op._res_scale, 0.5)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__sample_scale(self):
def test_sample_scale(self):
op = ipoverrides.IpOverrides(None)
op._sample_scale = 0.5
self.assertEqual(op.sample_scale, 0.5)
@@ -162,7 +158,7 @@ def test_property__sample_scale(self):
self.assertEqual(op._sample_scale, 0.5)
@patch.object(ipoverrides.IpOverrides, "__init__", lambda x, y: None)
def test_property__transparent_samples(self):
def test_transparent_samples(self):
op = ipoverrides.IpOverrides(None)
op._transparent_samples = 4
self.assertEqual(op.transparent_samples, 4)
@@ -857,7 +853,7 @@ def test(self):
class Test_build_arg_string_from_node(unittest.TestCase):
"""Test the ht.pyfilter.operations.ipoverrides.build_arg_string_from_node."""
@patch.object(ipoverrides.IpOverrides, "build_arg_string")
@patch("ht.pyfilter.operations.ipoverrides.IpOverrides.build_arg_string")
def test(self, mock_build):
mock_node = MagicMock()
mock_node.evalParm.return_value = 0
@@ -902,7 +898,7 @@ def test(self, mock_build):
transparent_samples=parm_data["ip_transparent_samples"],
)
@patch.object(ipoverrides.IpOverrides, "build_arg_string")
@patch("ht.pyfilter.operations.ipoverrides.IpOverrides.build_arg_string")
def test_no_scales(self, mock_build):
mock_node = MagicMock()
mock_node.evalParm.return_value = 0
@@ -1099,10 +1095,4 @@ def test(self):
if __name__ == '__main__':
# Run the tests.
try:
unittest.main()
finally:
cov.stop()
cov.html_report()
cov.save()
unittest.main()
@@ -1,19 +1,23 @@
"""Test the ht.pyfilter.operations.operation module."""
# =============================================================================
# IMPORTS
# =============================================================================
import coverage
import unittest
# Python Imports
from mock import MagicMock, patch
import unittest
from ht.pyfilter.operations import operation
# Houdini Toolbox Imports
from ht.pyfilter.manager import PyFilterManager
cov = coverage.Coverage(source=["ht.pyfilter.operations.operation"], branch=True)
cov.start()
from ht.pyfilter.operations import operation
reload(operation)
# =============================================================================
# CLASSES
# =============================================================================
class Test_PyFilterOperation(unittest.TestCase):
"""Test the ht.pyfilter.operations.operation.PyFilterOperation object."""
@@ -79,12 +83,4 @@ def test_should_run(self):
# =============================================================================
if __name__ == '__main__':
try:
# Run the tests.
unittest.main()
finally:
cov.stop()
cov.save()
cov.html_report()
unittest.main()
@@ -1,19 +1,23 @@
"""Test the ht.pyfilter.operations.primaryimage module."""
import argparse
import coverage
import unittest
# =============================================================================
# IMPORTS
# =============================================================================
# Python Imports
import argparse
from mock import MagicMock, call, patch
import unittest
from ht.pyfilter.operations import primaryimage
# Houdini Toolbox Imports
from ht.pyfilter.manager import PyFilterManager
cov = coverage.Coverage(source=["ht.pyfilter.operations.primaryimage"], branch=True)
cov.start()
from ht.pyfilter.operations import primaryimage
reload(primaryimage)
# =============================================================================
# CLASSES
# =============================================================================
class Test_SetPrimaryImage(unittest.TestCase):
"""Test the ht.pyfilter.operations.primaryimage.SetPrimaryImage object."""
@@ -195,12 +199,4 @@ def test_should_run__no_op(self):
# =============================================================================
if __name__ == '__main__':
try:
# Run the tests.
unittest.main()
finally:
cov.stop()
cov.save()
cov.html_report()
unittest.main()
@@ -4,19 +4,15 @@
# IMPORTS
# =============================================================================
# Standard Library Imports
# Python Imports
import argparse
import coverage
from mock import MagicMock, call, patch
import unittest
# Houdini Toolbox Imports
from ht.pyfilter.manager import PyFilterManager
from ht.pyfilter.operations import zdepth
cov = coverage.coverage(data_suffix=True, source=["ht.pyfilter.operations.zdepth"], branch=True)
cov.start()
reload(zdepth)
# =============================================================================
@@ -308,10 +304,4 @@ def test_should_run(self):
# =============================================================================
if __name__ == '__main__':
# Run the tests.
try:
unittest.main()
finally:
cov.stop()
cov.html_report()
cov.save()
unittest.main()
Oops, something went wrong.

0 comments on commit c3f77d1

Please sign in to comment.