MCPcopy
hub / github.com/pytest-dev/pytest / check

Method check

src/_pytest/_py/path.py:773–799  ·  src/_pytest/_py/path.py::LocalPath.check

Check a path for existence and properties. Without arguments, return True if the path exists, otherwise False. valid checkers:: file = 1 # is a file file = 0 # is not a file (may not even exist) dir = 1 # is a dir link = 1 # is a

(self, **kw)

Source from the content-addressed store, hash-verified

771 return islink(self.strpath)
772
773 def check(self, **kw):
774 class="st">"""Check a path for existence and properties.
775
776 Without arguments, return True if the path exists, otherwise False.
777
778 valid checkers::
779
780 file = 1 class="cm"># is a file
781 file = 0 class="cm"># is not a file (may not even exist)
782 dir = 1 class="cm"># is a dir
783 link = 1 class="cm"># is a link
784 exists = 1 class="cm"># exists
785
786 You can specify multiple checker definitions, for example::
787
788 path.check(file=1, link=1) class="cm"># a link pointing to a file
789 class="st">"""
790 if not kw:
791 return exists(self.strpath)
792 if len(kw) == 1:
793 if class="st">"dir" in kw:
794 return not kw[class="st">"dir"] ^ isdir(self.strpath)
795 if class="st">"file" in kw:
796 return not kw[class="st">"file"] ^ isfile(self.strpath)
797 if not kw:
798 kw = {class="st">"exists": 1}
799 return Checkers(self)._evaluate(kw)
800
801 _patternchars = set(class="st">"*?[" + os.sep)
802

Callers 13

existsMethod · 0.95
isdirMethod · 0.95
isfileMethod · 0.95
removeMethod · 0.95
copyMethod · 0.95
_ensuredirsMethod · 0.95
pyimportMethod · 0.95
_check_checkMethod · 0.45
genMethod · 0.45
chownMethod · 0.45
recMethod · 0.45
ensureMethod · 0.45

Calls 2

CheckersClass · 0.85
_evaluateMethod · 0.80

Tested by

no test coverage detected