Skip to content

remove the py.path.local() and replace it with os.getcwd() #2663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _set_initial_conftests(self, namespace):
been loaded, however, so common options will not confuse our logic
here.
"""
current = py.path.local()
current = os.getcwd()
self._confcutdir = current.join(namespace.confcutdir, abs=True) \
if namespace.confcutdir else None
self._noconftest = namespace.noconftest
Expand Down Expand Up @@ -988,7 +988,7 @@ def _initini(self, args):
self.rootdir, self.inifile, self.inicfg = r
self._parser.extra_info['rootdir'] = self.rootdir
self._parser.extra_info['inifile'] = self.inifile
self.invocation_dir = py.path.local()
self.invocation_dir = os.getcwd()
self._parser.addini('addopts', 'extra command line options', 'args')
self._parser.addini('minversion', 'minimally required pytest version')
self._override_ini = ns.override_ini or ()
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def getcfg(args, warnfunc=None):
inibasenames = ["pytest.ini", "tox.ini", "setup.cfg"]
args = [x for x in args if not str(x).startswith("-")]
if not args:
args = [py.path.local()]
args = [os.getcwd()]
for arg in args:
arg = py.path.local(arg)
for base in arg.parts(reverse=True):
Expand Down Expand Up @@ -1291,7 +1291,7 @@ def get_common_ancestor(paths):
if shared is not None:
common_ancestor = shared
if common_ancestor is None:
common_ancestor = py.path.local()
common_ancestor = os.getcwd()
elif common_ancestor.isfile():
common_ancestor = common_ancestor.dirpath()
return common_ancestor
Expand Down Expand Up @@ -1342,7 +1342,7 @@ def determine_setup(inifile, args, warnfunc=None):
else:
rootdir, inifile, inicfg = getcfg(dirs, warnfunc=warnfunc)
if rootdir is None:
rootdir = get_common_ancestor([py.path.local(), ancestor])
rootdir = get_common_ancestor([os.getcwd(), ancestor])
is_fs_root = os.path.splitdrive(str(rootdir))[1] == os.sep
if is_fs_root:
rootdir = ancestor
Expand Down
2 changes: 1 addition & 1 deletion _pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def __init__(self, config):
self.shouldstop = False
self.trace = config.trace.root.get("collection")
self._norecursepatterns = config.getini("norecursedirs")
self.startdir = py.path.local()
self.startdir = os.getcwd()
self.config.pluginmanager.register(self, name="session")

def _makeid(self):
Expand Down
2 changes: 1 addition & 1 deletion _pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ def _run(self, *cmdargs):
p1 = self.tmpdir.join("stdout")
p2 = self.tmpdir.join("stderr")
print("running:", ' '.join(cmdargs))
print(" in:", str(py.path.local()))
print(" in:", str(os.getcwd()))
f1 = codecs.open(str(p1), "w", encoding="utf8")
f2 = codecs.open(str(p2), "w", encoding="utf8")
try:
Expand Down
4 changes: 2 additions & 2 deletions _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def show_fixtures_per_test(config):
def _show_fixtures_per_test(config, session):
import _pytest.config
session.perform_collect()
curdir = py.path.local()
curdir = os.getcwd()
tw = _pytest.config.create_terminal_writer(config)
verbose = config.getvalue("verbose")

Expand Down Expand Up @@ -1034,7 +1034,7 @@ def showfixtures(config):
def _showfixtures_main(config, session):
import _pytest.config
session.perform_collect()
curdir = py.path.local()
curdir = os.getcwd()
tw = _pytest.config.create_terminal_writer(config)
verbose = config.getvalue("verbose")

Expand Down
3 changes: 1 addition & 2 deletions _pytest/resultlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import absolute_import, division, print_function

import py
import os


Expand Down Expand Up @@ -109,5 +108,5 @@ def pytest_internalerror(self, excrepr):
reprcrash = getattr(excrepr, 'reprcrash', None)
path = getattr(reprcrash, "path", None)
if path is None:
path = "cwd:%s" % py.path.local()
path = "cwd:%s" % os.getcwd()
self.write_log_entry(path, '!', str(excrepr))
2 changes: 1 addition & 1 deletion _pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(self, config, file=None):
self._numcollected = 0

self.stats = {}
self.startdir = py.path.local()
self.startdir = os.getcwd()
if file is None:
file = sys.stdout
self._tw = self.writer = _pytest.config.create_terminal_writer(config,
Expand Down