Skip to content

Commit 5f880fb

Browse files
committed
Add Travis Test integration
1 parent 444fe96 commit 5f880fb

3 files changed

Lines changed: 14 additions & 21 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ python:
55
install: "pip install -r requirements.txt"
66
# command to run tests
77
script:
8-
- echo "TODO"
8+
- python -m tests.test_linter

test_runner.py

Whitespace-only changes.

tests/test_linter.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
11
import unittest
22
from PythonBuddy.app import *
33

4-
# Testing Flask Views
5-
# class TestPylint(unittest.TestCase):
6-
#
7-
# def test_pylint(self):
8-
# test_code_1 = "print(\"hello world\")"
9-
# self.assertEqual(app.check_code(test_code_1), '{}')
10-
#
11-
# def test_isupper(self):
12-
# self.assertTrue('FOO'.isupper())
13-
# self.assertFalse('Foo'.isupper())
14-
#
15-
# def test_split(self):
16-
# s = 'hello world'
17-
# self.assertEqual(s.split(), ['hello', 'world'])
18-
# # check that s.split fails when the separator is not a string
19-
# with self.assertRaises(TypeError):
20-
# s.split(2)
21-
22-
# Testing individual functions
234
class TestProcessingFunctions(unittest.TestCase):
5+
# def test_evaluate_pylint(self):
6+
# test_code = "def foo(bar, baz):\n pass\nfoo(42)"
7+
# self.assertNotEqual(evaluate_pylint(test_code), {})
8+
9+
# def test_slow(self):
10+
# self.assertFalse(slow())
11+
2412
def test_format_errors(self):
2513
# self.assertEqual(format_errors(""), {})
14+
test_errors="************* Module tmp9utinlsg\r\n \/tmp\/tmp9utinlsg:1: warning (W0613, unused-argument, foo) Unused argument 'bar'\r\n \/tmp\/tmp9utinlsg:1: warning (W0613, unused-argument, foo) Unused argument 'baz'\r\n \/tmp\/tmp9utinlsg:3: error (E1120, no-value-for-parameter, ) No value for argument 'baz' in function call\r\n \r\n ----------------------------------------------------------------------\r\n Your code has been rated at -13.33\/10 (previous run: -13.33\/10, +0.00)\r\n \r\n \r\n"
15+
self.assertEqual(format_errors(test_errors), [{'code': 'W0613', 'error': 'unused-argument', 'message': 'Unused argument', 'line': '1', 'error_info': ' \r Occurs when a function or method argument is not used.\r'}, {'code': 'W0613', 'error': 'unused-argument', 'message': 'Unused argument', 'line': '1', 'error_info': ' \r Occurs when a function or method argument is not used.\r'}, {'code': 'E1120', 'error': 'no-value-for-parameter', 'message': "No value for argument 'baz' in function", 'line': '3', 'error_info': ' \r Occurs when a function call passes too few arguments.\r'}, None, None, None, None, None])
2616
self.assertEqual(format_errors("\n\n"), [None])
17+
2718
def test_process_error(self):
19+
test_error = " \/tmp\/tmp9utinlsg:3: error (E1120, no-value-for-parameter, ) No value for argument 'baz' in function call\r\n"
20+
print(process_error(test_error))
21+
self.assertEqual(process_error(test_error), {'code': 'E1120', 'error': 'no-value-for-parameter', 'message': "No value for argument 'baz' in function", 'line': '3', 'error_info': ' \r Occurs when a function call passes too few arguments.\r'})
2822
self.assertEqual(process_error(None), None)
2923
self.assertEqual(process_error(""), None)
3024

31-
3225
if __name__ == '__main__':
3326
# print(process_error("s"))
3427
unittest.main()

0 commit comments

Comments
 (0)