Spaces Data
Minimal test - lines (375, 470)
path: .spaces[5].metrics.loc.cloc
old: 2.0
new: 5.0
path: .spaces[5].metrics.loc.sloc
old: 92.0
new: 96.0
path: .spaces[5].metrics.loc.blank
old: 11.0
new: 12.0
path: .spaces[5].metrics.mi.mi_original
old: 45.13543222395923
new: 44.44596647037474
path: .spaces[5].metrics.mi.mi_sei
old: 4.91217870112734
new: 9.907417346923726
path: .spaces[5].metrics.mi.mi_visual_studio
old: 26.394989604654516
new: 25.99179325752909
Code
class TestExecution:
pytestmark = skiponwin32
def test_sysfind_no_permisson_ignored(self, monkeypatch, tmpdir):
noperm = tmpdir.ensure('noperm', dir=True)
monkeypatch.setenv("PATH", noperm, prepend=":")
noperm.chmod(0)
assert py.path.local.sysfind('jaksdkasldqwe') is None
def test_sysfind_absolute(self):
x = py.path.local.sysfind('test')
assert x.check(file=1)
y = py.path.local.sysfind(str(x))
assert y.check(file=1)
assert y == x
def test_sysfind_multiple(self, tmpdir, monkeypatch):
monkeypatch.setenv('PATH', "%s:%s" % (
tmpdir.ensure('a'),
tmpdir.join('b')),
prepend=":")
tmpdir.ensure('b', 'a')
x = py.path.local.sysfind(
'a', checker=lambda x: x.dirpath().basename == 'b')
assert x.basename == 'a'
assert x.dirpath().basename == 'b'
assert py.path.local.sysfind('a', checker=lambda x: None) is None
def test_sysexec(self):
x = py.path.local.sysfind('ls')
out = x.sysexec('-a')
for x in py.path.local().listdir():
assert out.find(x.basename) != -1
def test_sysexec_failing(self):
x = py.path.local.sysfind('false')
with pytest.raises(py.process.cmdexec.Error):
x.sysexec('aksjdkasjd')
def test_make_numbered_dir(self, tmpdir):
tmpdir.ensure('base.not_an_int', dir=1)
for i in range(10):
numdir = local.make_numbered_dir(prefix='base.', rootdir=tmpdir,
keep=2, lock_timeout=0)
assert numdir.check()
assert numdir.basename == 'base.%d' % i
if i >= 1:
assert numdir.new(ext=str(i-1)).check()
if i >= 2:
assert numdir.new(ext=str(i-2)).check()
if i >= 3:
assert not numdir.new(ext=str(i-3)).check()
def test_make_numbered_dir_case_insensitive(self, tmpdir, monkeypatch):
# https://github.com/pytest-dev/pytest/issues/708
monkeypatch.setattr(py._path.local, 'normcase',
lambda path: path.lower())
monkeypatch.setattr(tmpdir, 'listdir',
lambda: [tmpdir._fastjoin('case.0')])
numdir = local.make_numbered_dir(prefix='CAse.', rootdir=tmpdir,
keep=2, lock_timeout=0)
assert numdir.basename.endswith('.1')
def test_make_numbered_dir_case_sensitive(self, tmpdir, monkeypatch):
# https://github.com/pytest-dev/pytest/issues/708
monkeypatch.setattr(py._path.local, 'normcase', lambda path: path)
monkeypatch.setattr(tmpdir, 'listdir',
lambda: [tmpdir._fastjoin('case.0')])
numdir = local.make_numbered_dir(prefix='CAse.', rootdir=tmpdir,
keep=2, lock_timeout=0)
assert numdir.basename.endswith('.0')
def test_make_numbered_dir_NotImplemented_Error(self, tmpdir, monkeypatch):
def notimpl(x, y):
raise NotImplementedError(42)
monkeypatch.setattr(os, 'symlink', notimpl)
x = tmpdir.make_numbered_dir(rootdir=tmpdir, lock_timeout=0)
assert x.relto(tmpdir)
assert x.check()
def test_locked_make_numbered_dir(self, tmpdir):
for i in range(10):
numdir = local.make_numbered_dir(prefix='base2.', rootdir=tmpdir,
keep=2)
assert numdir.check()
assert numdir.basename == 'base2.%d' % i
for j in range(i):
assert numdir.new(ext=str(j)).check()
def test_error_preservation(self, path1):
py.test.raises(EnvironmentError, path1.join('qwoeqiwe').mtime)
py.test.raises(EnvironmentError, path1.join('qwoeqiwe').read)
# def test_parentdirmatch(self):
# local.parentdirmatch('std', startmodule=__name__)
#