@@ -757,12 +757,30 @@ def test_makedev(self):
757757 self .assertRaises ((ValueError , OverflowError ), posix .makedev , x , minor )
758758 self .assertRaises ((ValueError , OverflowError ), posix .makedev , major , x )
759759
760- if sys .platform == 'linux' and not support .linked_to_musl ():
761- NODEV = - 1
760+ # The following tests are needed to test functions accepting or
761+ # returning the special value NODEV (if it is defined). major(), minor()
762+ # and makefile() are the only easily reproducible examples, but that
763+ # behavior is platform specific -- on some platforms their code has
764+ # a special case for NODEV, on others this is just an implementation
765+ # artifact.
766+ if (hasattr (posix , 'NODEV' ) and
767+ sys .platform .startswith (('linux' , 'macos' , 'freebsd' , 'dragonfly' ,
768+ 'sunos' ))):
769+ NODEV = posix .NODEV
762770 self .assertEqual (posix .major (NODEV ), NODEV )
763771 self .assertEqual (posix .minor (NODEV ), NODEV )
764772 self .assertEqual (posix .makedev (NODEV , NODEV ), NODEV )
765773
774+ def test_nodev (self ):
775+ # NODEV is not a part of Posix, but is defined on many systems.
776+ if (not hasattr (posix , 'NODEV' )
777+ and (not sys .platform .startswith (('linux' , 'macos' , 'freebsd' ,
778+ 'dragonfly' , 'netbsd' , 'openbsd' ,
779+ 'sunos' ))
780+ or support .linked_to_musl ())):
781+ self .skipTest ('not defined on this platform' )
782+ self .assertHasAttr (posix , 'NODEV' )
783+
766784 def _test_all_chown_common (self , chown_func , first_param , stat_func ):
767785 """Common code for chown, fchown and lchown tests."""
768786 def check_stat (uid , gid ):
0 commit comments