Use the system independent null device provided by python
authorPlamen Dimitrov <pdimitrov@pevogam.com>
Fri, 15 Jun 2018 18:12:12 +0000 (01:12 +0700)
committerPlamen Dimitrov <pdimitrov@pevogam.com>
Tue, 23 Oct 2018 07:23:02 +0000 (15:23 +0800)
test/test_cnfvar.py

index dc5e1a6..3a0f18a 100755 (executable)
@@ -341,39 +341,39 @@ demo_cnf_comments = b"""
 class CnfVarUnittest(unittest.TestCase):
 
     def test_print_cnf(self):
-        with open("/dev/null", "w") as devnull:
+        with open(os.devnull, "w") as devnull:
             cnfvar.print_cnf(demo_cnfvar, out=devnull)
 
     def test_parse_cnf_simple(self):
         cnf = cnfvar.read_cnf(demo_cnf_group)
-        with open("/dev/null", "w") as devnull:
+        with open(os.devnull, "w") as devnull:
             cnfvar.print_cnf_json(cnf, out=devnull)
 
     def test_parse_cnf_nested(self):
         cnf = cnfvar.read_cnf(demo_cnf_filter)
-        with open("/dev/null", "w") as devnull:
+        with open(os.devnull, "w") as devnull:
             cnfvar.print_cnf_json(cnf, out=devnull)
 
     def test_parse_cnf_comments(self):
         cnf = cnfvar.read_cnf(demo_cnf_comments)
-        with open("/dev/null", "w") as devnull:
+        with open(os.devnull, "w") as devnull:
             cnfvar.print_cnf_json(cnf, out=devnull)
 
     def test_print_cnf_garbage(self):
         try:
-            with open("/dev/null", "w") as devnull:
+            with open(os.devnull, "w") as devnull:
                 cnfvar.print_cnf(demo_invalid_cnfvar, out=devnull)
         except cnfvar.InvalidCNF:
             print ("Caught the duplicate line, bravo!")
 
     def test_read_json(self):
         cnf = cnfvar.read_cnf_json(demo_jsoncnf)
-        with open("/dev/null", "w") as devnull:
+        with open(os.devnull, "w") as devnull:
             cnfvar.print_cnf(cnf, out=devnull)
 
     def test_read_json_nonascii(self):
         cnf = cnfvar.read_cnf_json(demo_latin1crap)
-        with open("/dev/null", "w") as devnull:
+        with open(os.devnull, "w") as devnull:
             cnfvar.print_cnf(cnf, out=devnull)