xfstestsdb/tests/xunit/test_xunit.py

32 lines
1.1 KiB
Python
Raw Normal View History

# Copyright 2023 (c) Anna Schumaker.
"""Tests the `xfstestsdb xunit` command."""
import argparse
import io
import unittest
import unittest.mock
import xfstestsdb
class TestXunit(unittest.TestCase):
"""Tests the `xfstestsdb xunit` command."""
def setUp(self):
"""Set up common variables."""
self.xfstestsdb = xfstestsdb.Command()
self.xunit = self.xfstestsdb.commands["xunit"]
def test_init(self):
"""Check that the xunit command was set up properly."""
self.assertIsInstance(self.xunit, xfstestsdb.commands.Command)
self.assertIsInstance(self.xunit, xfstestsdb.xunit.Command)
self.assertIsInstance(self.xunit.subparser, argparse.Action)
self.assertEqual(self.xfstestsdb.subparser.choices["xunit"],
self.xunit.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(["xunit"])
self.assertRegex(mock_stdout.getvalue(),
r"^usage: .*? xunit \[\-h\] \{.*?} ...$")