1
1
# -*- coding: utf-8 -*-
2
+ import os
2
3
import sys
3
4
4
5
import _pytest ._code
@@ -513,22 +514,12 @@ def test_pyargs_importerror(self, testdir, monkeypatch):
513
514
path = testdir .mkpydir ("tpkg" )
514
515
path .join ("test_hello.py" ).write ('raise ImportError' )
515
516
516
- result = testdir .runpytest ("--pyargs" , "tpkg.test_hello" )
517
+ result = testdir .runpytest_subprocess ("--pyargs" , "tpkg.test_hello" )
517
518
assert result .ret != 0
518
519
519
- # Depending on whether the process running the test is the
520
- # same as the process parsing the command-line arguments, the
521
- # type of failure can be different:
522
- if result .stderr .str () == '' :
523
- # Different processes
524
- result .stdout .fnmatch_lines ([
525
- "collected*0*items*/*1*errors"
526
- ])
527
- else :
528
- # Same process
529
- result .stderr .fnmatch_lines ([
530
- "ERROR:*file*or*package*not*found:*tpkg.test_hello"
531
- ])
520
+ result .stdout .fnmatch_lines ([
521
+ "collected*0*items*/*1*errors"
522
+ ])
532
523
533
524
def test_cmdline_python_package (self , testdir , monkeypatch ):
534
525
monkeypatch .delenv ('PYTHONDONTWRITEBYTECODE' , False )
@@ -549,7 +540,7 @@ def test_cmdline_python_package(self, testdir, monkeypatch):
549
540
def join_pythonpath (what ):
550
541
cur = py .std .os .environ .get ('PYTHONPATH' )
551
542
if cur :
552
- return str (what ) + ':' + cur
543
+ return str (what ) + os . pathsep + cur
553
544
return what
554
545
empty_package = testdir .mkpydir ("empty_package" )
555
546
monkeypatch .setenv ('PYTHONPATH' , join_pythonpath (empty_package ))
@@ -560,11 +551,10 @@ def join_pythonpath(what):
560
551
])
561
552
562
553
monkeypatch .setenv ('PYTHONPATH' , join_pythonpath (testdir ))
563
- path .join ('test_hello.py' ).remove ()
564
- result = testdir .runpytest ("--pyargs" , "tpkg.test_hello" )
554
+ result = testdir .runpytest ("--pyargs" , "tpkg.test_missing" )
565
555
assert result .ret != 0
566
556
result .stderr .fnmatch_lines ([
567
- "*not*found*test_hello *" ,
557
+ "*not*found*test_missing *" ,
568
558
])
569
559
570
560
def test_cmdline_python_namespace_package (self , testdir , monkeypatch ):
@@ -605,7 +595,7 @@ def join_pythonpath(*dirs):
605
595
cur = py .std .os .environ .get ('PYTHONPATH' )
606
596
if cur :
607
597
dirs += (cur ,)
608
- return ':' .join (str (p ) for p in dirs )
598
+ return os . pathsep .join (str (p ) for p in dirs )
609
599
monkeypatch .setenv ('PYTHONPATH' , join_pythonpath (* search_path ))
610
600
for p in search_path :
611
601
monkeypatch .syspath_prepend (p )
0 commit comments