xfstestsdb/tests/testcase/test_testcase.py

32 lines
1.2 KiB
Python
Raw Normal View History

# Copyright 2023 (c) Anna Schumaker.
"""Tests the `xfstestsdb testcase` command."""
import argparse
import io
import unittest
import unittest.mock
import xfstestsdb
class TestTestcase(unittest.TestCase):
"""Tests the `xfstestsdb testcase` command."""
def setUp(self):
"""Set up common variables."""
self.xfstestsdb = xfstestsdb.Command()
self.testcase = self.xfstestsdb.commands["testcase"]
def test_init(self):
"""Check that the testcase command was set up properly."""
self.assertIsInstance(self.testcase, xfstestsdb.commands.Command)
self.assertIsInstance(self.testcase, xfstestsdb.testcase.Command)
self.assertIsInstance(self.testcase.subparser, argparse.Action)
self.assertEqual(self.xfstestsdb.subparser.choices["testcase"],
self.testcase.parser)
@unittest.mock.patch("sys.stdout", new_callable=io.StringIO)
def test_xunit_empty(self, mock_stdout: io.StringIO):
"""Test calling `xfstestdb xunit` with an empty argument list."""
self.xfstestsdb.run(["testcase"])
self.assertRegex(mock_stdout.getvalue(),
r"^usage: .*? testcase \[\-h\] \{.*?} ...$")