Browse Source

configure pytest not to interfere with our forking

Malte Kraus 8 years ago
parent
commit
001f9bc6d6
4 changed files with 5 additions and 10 deletions
  1. 2 0
      pytest.ini
  2. 0 1
      src/__init__.py
  3. 3 6
      src/mining.py
  4. 0 3
      tests/test_proto.py

+ 2 - 0
pytest.ini

@@ -0,0 +1,2 @@
+[pytest]
+addopts=--capture=sys

+ 0 - 1
src/__init__.py

@@ -1 +0,0 @@
-_run_from_test = False

+ 3 - 6
src/mining.py

@@ -40,12 +40,9 @@ def start_process(func: Callable) -> Tuple[int, int]:
     pid = os.fork()
     if pid == 0: # child
         try:
-            # pytest opens some weird file descriptors...
-            import src
-            if not src._run_from_test:
-                os.close(0)
-                os.closerange(3, wx)
-                os.closerange(wx + 1, 2**16)
+            os.close(0)
+            os.closerange(3, wx)
+            os.closerange(wx + 1, 2**16)
 
             Thread(target=exit_on_pipe_close, args=(wx,), daemon=True).start()
 

+ 0 - 3
tests/test_proto.py

@@ -2,9 +2,6 @@ from time import sleep
 import logging
 #logging.basicConfig(level=logging.DEBUG)
 
-import src
-src._run_from_test = True
-
 from src.protocol import Protocol
 from src.mining import Miner
 from src.block import GENESIS_BLOCK