Skip to content
This repository was archived by the owner on Nov 11, 2019. It is now read-only.

Commit bcc34de

Browse files
committed
Cosmetic: Clean up tests
* rename test cases to conform to conventions for pytest discovery * nix unittest stuff since we're not using it at all and it makes using fixtures more difficult
1 parent ea85a90 commit bcc34de

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

tests/test_cmdline.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
from unittest import TestCase
32

43
from click.testing import CliRunner
54

@@ -12,7 +11,7 @@
1211
# http://click.pocoo.org/5/testing/#file-system-isolation
1312

1413

15-
class CmdlineHelpTestCase(TestCase):
14+
class TestCmdlineHelp:
1615
def test_help(self):
1716
"""Basic test to make sure the cli works"""
1817
runner = CliRunner()
@@ -21,7 +20,7 @@ def test_help(self):
2120
assert 'Usage' in result.output.splitlines()[0]
2221

2322

24-
class CreateprojectTestCase(TestCase):
23+
class TestCreateproject:
2524
def test_help(self):
2625
runner = CliRunner()
2726
result = runner.invoke(cli, ('createproject', '--help'))
@@ -50,7 +49,7 @@ def test_directory_already_exists(self):
5049
assert '{0} exists.'.format(os.path.join(path, 'testprj')) in result.output
5150

5251

53-
class FetchTestCase(TestCase):
52+
class TestFetch:
5453
def test_help(self):
5554
runner = CliRunner()
5655
result = runner.invoke(cli, ('fetch', '--help'))
@@ -59,7 +58,7 @@ def test_help(self):
5958
# FIXME: More extensive tests
6059

6160

62-
class PullTestCase(TestCase):
61+
class TestPull:
6362
def test_help(self):
6463
runner = CliRunner()
6564
result = runner.invoke(cli, ('pull', '--help'))
@@ -68,7 +67,7 @@ def test_help(self):
6867
# FIXME: More extensive tests
6968

7069

71-
class PushTestCase(TestCase):
70+
class TestPush:
7271
def test_help(self):
7372
runner = CliRunner()
7473
result = runner.invoke(cli, ('push', '--help'))
@@ -77,7 +76,7 @@ def test_help(self):
7776
# FIXME: More extensive tests
7877

7978

80-
class ScrapevideoTestCase(TestCase):
79+
class TestScrapevideo:
8180
def test_help(self):
8281
runner = CliRunner()
8382
result = runner.invoke(cli, ('scrapevideo', '--help'))
@@ -86,7 +85,7 @@ def test_help(self):
8685
# FIXME: More extensive tests
8786

8887

89-
class StatusTestCase(TestCase):
88+
class TestStatus:
9089
def test_help(self):
9190
runner = CliRunner()
9291
result = runner.invoke(cli, ('status', '--help'))
@@ -95,7 +94,7 @@ def test_help(self):
9594
# FIXME: More extensive tests
9695

9796

98-
class VerifyTestCase(TestCase):
97+
class TestVerify:
9998
def test_help(self):
10099
runner = CliRunner()
101100
result = runner.invoke(cli, ('verify', '--help'))
@@ -104,7 +103,7 @@ def test_help(self):
104103
# FIXME: More extensive tests
105104

106105

107-
class WebeditTestCase(TestCase):
106+
class TestWebedit:
108107
def test_help(self):
109108
runner = CliRunner()
110109
result = runner.invoke(cli, ('webedit', '--help'))

tests/test_restapi.py

+9-18
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,16 @@
66
# license.
77
#######################################################################
88

9-
from unittest import TestCase
10-
119
from steve.restapi import urljoin
1210

1311

14-
class UrlJoinTestCase(TestCase):
15-
def test_urljoin(self):
16-
for base, args, expected in [
17-
('http://localhost', ['path1'],
18-
'http://localhost/path1'),
19-
20-
('http://localhost/path1', ['path2'],
21-
'http://localhost/path1/path2'),
22-
23-
('http://localhost', ['path1', 'path2'],
24-
'http://localhost/path1/path2'),
25-
26-
('http://localhost?foo=bar', ['path1'],
27-
'http://localhost/path1?foo=bar'),
28-
]:
12+
def test_urljoin():
13+
data = [
14+
('http://localhost', ['path1'], 'http://localhost/path1'),
15+
('http://localhost/path1', ['path2'], 'http://localhost/path1/path2'),
16+
('http://localhost', ['path1', 'path2'], 'http://localhost/path1/path2'),
17+
('http://localhost?foo=bar', ['path1'], 'http://localhost/path1?foo=bar'),
18+
]
2919

30-
assert urljoin(base, *args) == expected
20+
for base, args, expected in data:
21+
assert urljoin(base, *args) == expected

tests/test_utils.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# license.
77
#######################################################################
88

9-
from unittest import TestCase
9+
import pytest
1010

1111
from steve.util import (
1212
get_video_id,
@@ -17,7 +17,7 @@
1717
)
1818

1919

20-
class VerifyVideoDataTestCase(TestCase):
20+
class TestVerifyVideoData:
2121
default = {
2222
'title': 'Foo',
2323
'category': 'Test Category',
@@ -160,8 +160,5 @@ def test_get_video_id():
160160
'http://pyvideo.org/video/foo'
161161
]
162162
for url in data:
163-
try:
163+
with pytest.raises(SteveException):
164164
get_video_id(url)
165-
assert False
166-
except SteveException:
167-
pass

0 commit comments

Comments
 (0)