1+ """Test :mod:`nodely.bin`."""
2+
13import os
24import platform
35import re
@@ -20,22 +22,19 @@ def test_NODE_MODULES_DIR():
2022
2123@pytest .mark .usefixtures ('install_node_package' )
2224class 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' )
6669class 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