Files
autospec/tests/test_buildpattern.py
T
Matthew Johnson 11569333b4 Add simple tests for buildpattern module
The complexity of the buildpattern has been significantly reduced with
the move to a centralized specfiles class to handle specfile writes.
This patch tests the remaining functionality and fixes a typo in
buildpattern.py (pattern_strengh -> pattern_strength).
2017-04-25 14:48:33 -07:00

44 lines
1.2 KiB
Python

import unittest
import buildpattern
class TestBuildpattern(unittest.TestCase):
def setUp(self):
"""
Test setup method to reset the buildpattern module
"""
buildpattern.default_pattern = "make"
buildpattern.pattern_strength = 0
buildpattern.sources = {
"unit": [],
"gcov": [],
"tmpfile": [],
"archive": []
}
buildpattern.source_index = {}
buildpattern.archive_details = {}
def test_set_build_pattern(self):
"""
Test set_build_pattern with sufficient pattern strength
"""
buildpattern.set_build_pattern("configure_ac", 1)
self.assertEqual(buildpattern.default_pattern, "configure_ac")
self.assertEqual(buildpattern.pattern_strength, 1)
def test_set_build_pattern_low_strength(self):
"""
Test set_build_pattern with low pattern strength, nothing in the module
should change
"""
buildpattern.pattern_strength = 2
buildpattern.set_build_pattern("configure_ac", 1)
self.assertEqual(buildpattern.default_pattern, "make")
self.assertEqual(buildpattern.pattern_strength, 2)
if __name__ == '__main__':
unittest.main(buffer=True)