Skip to content

Commit

Permalink
ENH: Avoid code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
flooklab committed Dec 4, 2020
1 parent 437dc2a commit cab7212
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 189 deletions.
7 changes: 6 additions & 1 deletion tests/test_SimGpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@


class TestSimGpio(unittest.TestCase):
def __init__(self, testname, tb='test_SimGpio.v', bus='basil.utils.sim.BasilBusDriver'):
super(TestSimGpio, self).__init__(testname)
self._test_tb = tb
self._sim_bus = bus

def setUp(self):
cocotb_compile_and_run([os.path.join(os.path.dirname(__file__), 'test_SimGpio.v')])
cocotb_compile_and_run(sim_files=[os.path.join(os.path.dirname(__file__), self._test_tb)], sim_bus=self._sim_bus)

self.chip = Dut(cnfg_yaml)
self.chip.init()
Expand Down
27 changes: 27 additions & 0 deletions tests/test_SimGpio_sbus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#

import unittest
import sys

from tests.test_SimGpio import TestSimGpio


if __name__ == '__main__':
# https://stackoverflow.com/a/2081750
test_loader = unittest.TestLoader()
test_names = test_loader.getTestCaseNames(TestSimGpio)

suite = unittest.TestSuite()

for test_name in test_names:
suite.addTest(TestSimGpio(test_name, 'test_SimGpio_sbus.v', 'basil.utils.sim.BasilSbusDriver'))
for test_name in test_names:
suite.addTest(TestSimGpio(test_name, 'test_SimGpio_sbus_top.v', 'basil.utils.sim.BasilSbusDriver'))

result = unittest.TextTestRunner().run(suite)
sys.exit(not result.wasSuccessful())
File renamed without changes.
94 changes: 0 additions & 94 deletions tests/test_SimGpio_sbus1.py

This file was deleted.

94 changes: 0 additions & 94 deletions tests/test_SimGpio_sbus2.py

This file was deleted.

File renamed without changes.

0 comments on commit cab7212

Please sign in to comment.