Skip to content

Commit 6e3aae2

Browse files
committed
Convert remainging unit tests ...
and reduce nose dependency.
1 parent 5f97ab2 commit 6e3aae2

9 files changed

Lines changed: 115 additions & 167 deletions

File tree

Makefile

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@ PYTHON ?= python3
99
RM ?= rm
1010
LINT =o flake8
1111

12-
#EXTRA_DIST=ipython/ipy_pydbgr.py pydbgr
1312
PHONY=check clean dist distclean test test-unit test-functional rmChangeLog nosetests flake8
1413

1514
#: Default target - same as "check"
16-
all: check
15+
all: test-unit
1716

1817
#: Same as "check"
1918
test: check
2019

21-
#: Run all tests: unit, functional and integration
22-
check-short: test-unit-short test-functional-short test-integration-short
23-
2420
# Check StructuredText long description formatting
2521
check-rst:
2622
$(PYTHON) setup.py --long-description | ./rst2html.py > python3-trepan.html
@@ -31,16 +27,11 @@ flake8:
3127

3228
#: Run all tests: unit, functional and integration verbosely
3329
# check: test-unit test-functional test-integration # flake8
34-
check: test-unit test-integration # flake8
30+
check: test-unit
3531

3632
#: Run unit (transparent-box) tests
3733
test-unit:
38-
$(PYTHON) -m pytest test/unit/lib test/unit/processor test/unit/test_*.py
39-
40-
#: Run unit (white-box) tests
41-
test-unit-short:
42-
$(PYTHON) ./setup.py nosetests --quiet | \
43-
$(PYTHON) ./make-check-filter.py
34+
$(PYTHON) -m pytest test/unit
4435

4536
#: Run functional tests
4637
test-functional:

test/make-check-filter.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/unit/inout/__init__.py

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Unit test for trepan.inout.input"""
2+
import os.path as osp
3+
4+
from trepan.inout.input import DebuggerUserInput
5+
6+
srcdir = osp.abspath(osp.dirname(__file__))
7+
8+
9+
def test_DebuggerInput():
10+
cmdhelper_file = osp.join(srcdir, "..", "cmdhelper.py")
11+
inp = DebuggerUserInput(cmdhelper_file)
12+
assert isinstance(
13+
inp, DebuggerUserInput
14+
), "Should have gotten a DebuggerUserInput object back"
15+
line = inp.readline()
16+
assert "# -*- coding: utf-8 -*-" == line
17+
inp.close()
18+
# Should be okay
19+
inp.close()
20+
return
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""Unit test for trepan.processor.subcmd"""
2+
import unittest
3+
4+
from trepan.processor.command.base_cmd import DebuggerCommand
5+
from trepan.processor.command.mock import MockDebugger
6+
from trepan.processor.subcmd import Subcmd
7+
8+
9+
class MyCommand(DebuggerCommand):
10+
"""Trepan processor Debugger Command base"""
11+
12+
category = "data"
13+
min_args = 0
14+
max_args = 5
15+
name_aliases = "mycommand"
16+
17+
def __init__(self):
18+
self.name = "test"
19+
return
20+
21+
def run(self, args):
22+
print("test command run")
23+
24+
pass
25+
26+
27+
class MySubcommand:
28+
"""Doc string for test testing subcommand"""
29+
30+
def __init__(self):
31+
self.name = "testing"
32+
return
33+
34+
short_help = "This is short help for test testing"
35+
min_abbrev = 4
36+
in_list = True
37+
38+
def run(self, args):
39+
print("test testing run")
40+
41+
pass
42+
43+
44+
class TestSubcommand(unittest.TestCase):
45+
def setUp(self):
46+
self.d = MockDebugger()
47+
self.mycmd = MyCommand()
48+
self.mycmd.debugger = self.d
49+
self.mycmd.proc = self.d.core.processor
50+
self.mycmdMgr = Subcmd("me", self.mycmd)
51+
self.testsub = MySubcommand()
52+
self.mycmdMgr.add(self.testsub)
53+
54+
def test_lookup(self):
55+
"""Test processor.subcmd.lookup()"""
56+
for prefix, expected in (
57+
("tes", "None"), # Too few chars
58+
("test", "testing"), # A valid abbrev
59+
("testing", "testing"), # equal name
60+
("testing1", "None"),
61+
): # Too long
62+
x = self.mycmdMgr.lookup(prefix)
63+
if x:
64+
s = x.name
65+
else:
66+
s = "None"
67+
self.assertEqual(
68+
expected,
69+
s,
70+
("prefix %s, expected: %s result: %s" % (prefix, expected, s)),
71+
)
72+
pass
73+
return
74+
75+
def test_list(self):
76+
"""Test processor.subcmd.list()"""
77+
self.assertEqual(["testing"], self.mycmdMgr.list())
78+
testsub2 = MySubcommand()
79+
testsub2.name = "foobar"
80+
self.mycmdMgr.add(testsub2)
81+
self.assertEqual(["foobar", "testing"], self.mycmdMgr.list())
82+
83+
pass
84+
85+
86+
if __name__ == "__main__":
87+
unittest.main()

test/unit/test-fifo.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/unit/test-inout-input.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/unit/test-subcmd.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

trepan/processor/command/set_subcmd/style.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2015, 2017-2018, 2020 Rocky Bernstein
2+
# Copyright (C) 2015, 2017-2018, 2020, 2024 Rocky Bernstein
33
#
44

55
from pygments.styles import STYLE_MAP
66

77
style_names = sorted(list(STYLE_MAP.keys()))
88

9-
# Our local modules
10-
from trepan.processor.command import base_subcmd as Mbase_subcmd
119
from trepan.lib import complete as Mcomplete
1210

11+
# Our local modules
12+
from trepan.processor.command.base_subcmd import DebuggerSubcommand
13+
1314

14-
class SetStyle(Mbase_subcmd.DebuggerSubcommand):
15+
class SetStyle(DebuggerSubcommand):
1516
"""**set style** [*pygments-style*]
1617
1718
Set the pygments style in to use in formatting text for a 256-color terminal.

0 commit comments

Comments
 (0)