aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/tests/base_tests.py
blob: cb57b3481feed6055952690271aa920245e2f53d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
# Copyright 2019 Ettus Research, a National Instruments Brand
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
"""
Base Test Case classes
"""

from test_utilities import on_linux, on_usrp
import unittest

class TestBase(unittest.TestCase):
    """
    Base Test Case class which contains commonly required functionality
    """
    def skipUnlessOnLinux():
        """
        Test function decorator which skips tests unless the current
        execution environment is a linux OS.
        """
        if on_linux():
            return lambda func: func
        return unittest.skip("This test is only valid when run on a Linux system.")

    def skipUnlessOnUsrp():
        """
        Test function decorator which skips tests unless the current
        execution environment is a USRP.
        """
        if on_usrp():
            return lambda func: func
        return unittest.skip("This test is only valid when run on the USRP.")

    def set_device_name(self, device_name):
        """
        Stores a device name attribute for tests whose success condition
        depends on the current device.
        """
        self.device_name = device_name