Skip to content

Commit 65cfacf

Browse files
Adapt tests to recent changes
1 parent 91817e3 commit 65cfacf

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

test/setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Setup for ``nodely-test``, a test package using ``nodely`` entry points."""
2+
13
import os # pragma: no cover
24
import sys # pragma: no cover
35

test/test_nodely.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_install(node_package):
2828

2929

3030
def test_install_non_existent():
31-
with pytest.raises(RuntimeError):
31+
with pytest.raises(nodely.NodeCommandError):
3232
nodely.install('non-existent')
3333

3434

test/test_nodely_bin.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Test :mod:`nodely.bin`."""
2+
13
import os
24
import platform
35
import re
@@ -20,22 +22,19 @@ def test_NODE_MODULES_DIR():
2022

2123
@pytest.mark.usefixtures('install_node_package')
2224
class TestModule(object):
23-
24-
def test__name__(self):
25-
assert nodely.bin.__name__ == nodely.bin.ORIGIN.__name__
26-
27-
def test__doc__(self):
28-
assert nodely.bin.__doc__ == nodely.bin.ORIGIN.__doc__
25+
"""Test module features of :mod:`nodely.bin`."""
2926

3027
def test__getitem__(self, node_package_command):
31-
command = nodely.bin[node_package_command]
28+
command = nodely.bin[ # pylint: disable=unsubscriptable-object
29+
node_package_command]
3230
assert type(command) is Command
3331
assert Path(command).normcase() \
3432
== nodely.which(node_package_command).normcase()
3533

3634
def test__getitem__non_existent(self):
3735
with pytest.raises((IOError, OSError)):
38-
nodely.bin['non-existent']
36+
nodely.bin[ # pylint: disable=unsubscriptable-object
37+
'non-existent']
3938

4039
def test__getattr__(self, node_package_command):
4140
command = getattr(nodely.bin, node_package_command)
@@ -44,26 +43,31 @@ def test__getattr__(self, node_package_command):
4443
== nodely.which(node_package_command).normcase()
4544

4645
def test__getattr__non_existent(self):
47-
with pytest.raises((IOError, OSError)):
46+
with pytest.raises(AttributeError, match=(
47+
r"^{} has no attribute 'non_existent' \(.+\)$"
48+
.format(re.escape(repr(nodely.bin))))):
49+
4850
getattr(nodely.bin, 'non_existent')
4951

5052
def test__getattr__non_existent__special__(self):
51-
with pytest.raises(AttributeError) as exc:
53+
with pytest.raises(AttributeError, match=(
54+
r"^{} has no attribute '__non_existent__'$"
55+
.format(re.escape(repr(nodely.bin))))):
56+
5257
getattr(nodely.bin, '__non_existent__')
53-
exc.match(
54-
r"^{!r} has no attribute '__non_existent__'$"
55-
.format(nodely.bin).replace('\\', r'\\'))
5658

5759
def test__dir__(self):
58-
cmdnames = (f.basename()
59-
for f in (nodely.bin.NODE_MODULES_DIR / '.bin').files())
60+
cmdnames = (
61+
f.basename()
62+
for f in (nodely.bin.NODE_MODULES_DIR / '.bin').files())
6063
if WIN:
6164
cmdnames = (cmd for cmd in cmdnames if cmd.ext.lower() != '.cmd')
6265
assert set(cmdnames).issubset(dir(nodely.bin))
6366

6467

6568
@pytest.mark.usefixtures('install_node_package')
6669
class TestCommand(object):
70+
"""Test :class:`nodely.bin.Command`."""
6771

6872
def test__new__(self, node_package_command):
6973
command = Command(node_package_command)

0 commit comments

Comments
 (0)