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

Method check

src/_pytest/_py/path.py:773–799  ·  view source on GitHub ↗

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 """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 # is a file
781 file = 0 # is not a file (may not even exist)
782 dir = 1 # is a dir
783 link = 1 # is a link
784 exists = 1 # exists
785
786 You can specify multiple checker definitions, for example::
787
788 path.check(file=1, link=1) # a link pointing to a file
789 """
790 if not kw:
791 return exists(self.strpath)
792 if len(kw) == 1:
793 if "dir" in kw:
794 return not kw["dir"] ^ isdir(self.strpath)
795 if "file" in kw:
796 return not kw["file"] ^ isfile(self.strpath)
797 if not kw:
798 kw = {"exists": 1}
799 return Checkers(self)._evaluate(kw)
800
801 _patternchars = set("*?[" + 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