Skip to content

Commit d36087e

Browse files
committed
Refactor tests
1 parent 52d5633 commit d36087e

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

.travis.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ python:
33
- "3.3"
44
- "3.4"
55
- "3.5"
6-
- "3.5-dev" # 3.5 development branch
7-
- "nightly" # currently points to 3.6-dev
8-
# command to run tests
6+
- "3.6"
97
install:
108
- pip install coveralls
119
- pip install coverage
1210
- pip install pylint
1311
script:
14-
- python -m unittest discover
1512
- pylint cheat
13+
- python -m unittest discover
1614
- coverage run -m unittest discover
1715
- coverage report -m
1816
after_success:

pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# pylint config
22
[MESSAGES CONTROL]
3-
disable=too-few-public-methods, line-too-long, no-name-in-module
3+
disable=too-few-public-methods, line-too-long, no-name-in-module, import-error

tests/test_main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_main_failure_no_cheatsheet(self):
5757
command = '/usr/bin/env python3 cheat/cheat.py not_available > /dev/null 2>&1'
5858
result = os.system(command)
5959

60-
self.assertEqual(result, self.exit_1)
60+
self.assertEqual(result, self.exit_2)
6161

6262
def test_main_failure_no_argument(self):
6363
"""

tests/test_printer.py tests/test_print.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import cheat.printer as cp
1111
import cheat.utils as u
1212

13+
1314
class PrinterTest(unittest.TestCase):
1415
"""
1516
Some basic tests to check the Printer classes.
@@ -22,7 +23,7 @@ def setUp(self):
2223
"""
2324

2425
directory = os.path.dirname(os.path.realpath(__file__))
25-
testfile = os.path.join(directory, "test.ini")
26+
testfile = os.path.join(directory, "testsheets", "test.ini")
2627
self.cparser = ConfigParser()
2728
self.cparser.read(testfile)
2829

@@ -67,7 +68,7 @@ def test_InlinePrinter_colored(self):
6768

6869
expected_output = lines[0] + lines[1] + lines[2]
6970

70-
printer = cp.InlinePrinter(self.cparser, u.colors, print_colored=True)
71+
printer = cp.InlinePrinter(self.cparser, u.Colors, print_colored=True)
7172

7273
with patch('sys.stdout', new=StringIO()) as fake_out:
7374
printer.printsheet()
@@ -86,7 +87,7 @@ def test_InlinePrinter(self):
8687

8788
expected_output = lines[0] + lines[1] + lines[2]
8889

89-
printer = cp.InlinePrinter(self.cparser, u.colors, print_colored=False)
90+
printer = cp.InlinePrinter(self.cparser, u.Colors, print_colored=False)
9091

9192
with patch('sys.stdout', new=StringIO()) as fake_out:
9293
printer.printsheet()
@@ -97,7 +98,7 @@ def test_InlinePrinter_width(self):
9798
Test to see if the calculated width is correct.
9899
"""
99100

100-
printer = cp.InlinePrinter(self.cparser, u.colors, print_colored=False)
101+
printer = cp.InlinePrinter(self.cparser, u.Colors, print_colored=False)
101102

102103
expected_length = str(len('Test Cheat A'))
103104
self.assertEqual(printer.width, expected_length)
@@ -114,7 +115,7 @@ def test_BreaklinePrinter(self):
114115

115116
expected_output = lines[0] + lines[1] + lines[2]
116117

117-
printer = cp.BreaklinePrinter(self.cparser, u.colors, print_colored=False)
118+
printer = cp.BreaklinePrinter(self.cparser, u.Colors, print_colored=False)
118119

119120
with patch('sys.stdout', new=StringIO()) as fake_out:
120121
printer.printsheet()
@@ -132,9 +133,9 @@ def test_Printer_printsheet(self):
132133

133134
expected_output = lines[0] + lines[1] + lines[2]
134135

135-
printer = cp.Printer(self.cparser, u.colors)
136+
printer = cp.Printer(self.cparser, u.Colors)
136137
template = "{0}"
137138

138139
with patch('sys.stdout', new=StringIO()) as fake_out:
139-
printer.printsheet(template)
140+
printer.printcheats(template)
140141
self.assertEqual(fake_out.getvalue(), expected_output)

tests/test_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ def test_print_available_sheets(self):
2828
Test of the print all cheatsheets function
2929
"""
3030

31-
expected_output = " unittest\n"
31+
expected_output = "unittest\n"
3232

3333
with patch('sys.stdout', new=StringIO()) as fake_out:
34-
u.print_available_sheets(self.directory)
34+
u.print_available_sheets(os.path.join(self.directory, "testsheets"))
3535
self.assertEqual(fake_out.getvalue(), expected_output)
3636

3737

@@ -41,6 +41,6 @@ def test_colors(self):
4141
"""
4242

4343
expected_output = "\033[94m"
44-
output = u.colors.DEFAULT
44+
output = u.Colors.DEFAULT
4545

4646
self.assertEqual(output, expected_output)
File renamed without changes.

0 commit comments

Comments
 (0)