Lines Matching refs:name

113 #    info about where the docstring came from (name, filename, lineno).
132 def register_optionflag(name):
133 # Create a new flag unless `name` is already known.
134 return OPTIONFLAGS_BY_NAME.setdefault(name, 1 << len(OPTIONFLAGS_BY_NAME))
200 module with that name.
330 # Get rid of everything except the exception name; in particular, drop
332 # any). We assume that a colon is never part of a dotted name, or of an
333 # exception name.
340 # The exception name must appear on the first line.
348 # retain just the exception name
515 - name: A name identifying the DocTest (typically, the name of
518 - filename: The name of the file that this DocTest was extracted
529 def __init__(self, examples, globs, name, filename, lineno, docstring):
539 self.name = name
552 self.name, self.filename, self.lineno, examples))
561 self.name == other.name and \
566 return hash((self.docstring, self.name, self.filename, self.lineno))
568 # This lets us sort tests by name:
572 return ((self.name, self.filename, self.lineno, id(self))
574 (other.name, other.filename, other.lineno, id(other)))
628 def parse(self, string, name='<string>'):
633 argument `name` is a name identifying this string, and is only
652 self._parse_example(m, name, lineno)
667 def get_doctest(self, string, globs, name, filename, lineno):
672 `globs`, `name`, `filename`, and `lineno` are attributes for
676 return DocTest(self.get_examples(string, name), globs,
677 name, filename, lineno, string)
679 def get_examples(self, string, name='<string>'):
687 The optional argument `name` is a name identifying this
690 return [x for x in self.parse(string, name)
693 def _parse_example(self, m, name, lineno):
701 `name` is the string's name, and `lineno` is the line number
710 self._check_prompt_blank(source_lines, indent, name, lineno)
711 self._check_prefix(source_lines[1:], ' '*indent + '.', name, lineno)
721 self._check_prefix(want_lines, ' '*indent, name,
733 options = self._find_options(source, name, lineno)
747 def _find_options(self, source, name, lineno):
752 `name` is the string's name, and `lineno` is the line number
764 (lineno+1, name, option))
770 (lineno, name, source))
785 def _check_prompt_blank(self, lines, indent, name, lineno):
796 (lineno+i+1, name,
799 def _check_prefix(self, lines, prefix, name, lineno):
808 (lineno+i+1, name, line))
846 def find(self, obj, name=None, module=None, globs=None, extraglobs=None):
860 - To find the name of the file containing the object.
881 # If name was not specified, then extract it from the object.
882 if name is None:
883 name = getattr(obj, '__name__', None)
884 if name is None:
885 raise ValueError("DocTestFinder.find: name must be given "
936 globs['__name__'] = '__main__' # provide a default module name
940 self._find(tests, obj, name, module, source_lines, globs, {})
988 def _find(self, tests, obj, name, module, source_lines, globs, seen):
994 print('Finding tests in %s' % name)
1002 test = self._get_test(obj, name, module, globs, source_lines)
1009 valname = '%s.%s' % (name, valname)
1030 valname = '%s.__test__.%s' % (name, valname)
1045 valname = '%s.%s' % (name, valname)
1049 def _get_test(self, obj, name, module, globs, source_lines):
1084 return self._parser.get_doctest(docstring, globs, name,
1152 >>> tests.sort(key = lambda test: test.name)
1154 ... print(test.name, '->', runner.run(test))
1282 (test.filename, lineno, test.name))
1284 out.append('Line %s, in %s' % (example.lineno+1, test.name))
1344 filename = '<doctest %s[%d]>' % (test.name, examplenum)
1424 f2, t2 = self._name2ft.get(test.name, (0,0))
1425 self._name2ft[test.name] = (f+f2, t+t2)
1430 r'(?P<name>.+)'
1434 if m and m.group('name') == self.test.name:
1531 name, (f, t) = x
1536 notests.append(name)
1538 passed.append( (name, t) )
1572 for name, (f, t) in other._name2ft.items():
1573 if name in d:
1576 #print("*** DocTestRunner.merge: '" + name + "' in both" \
1578 f2, t2 = d[name]
1581 d[name] = f, t
1879 def testmod(m=None, name=None, globs=None, verbose=None,
1882 """m=None, name=None, globs=None, verbose=None, report=True,
1892 function and class docstrings are tested even if the name is private;
1899 Optional keyword arg "name" gives the name of the module; by default
1958 # If no name was given, then use the module's name.
1959 if name is None:
1960 name = m.__name__
1970 for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
1983 def testfile(filename, module_relative=True, name=None, package=None,
2005 Optional keyword arg "name" gives the name of the test; by default
2009 name of a Python package whose directory should be used as the
2073 # If no name was given, then use the file's name.
2074 if name is None:
2075 name = os.path.basename(filename)
2093 test = parser.get_doctest(text, globs, name, filename, 0)
2106 def run_docstring_examples(f, globs, verbose=False, name="NoName",
2110 as globals. Optional argument `name` is used in failure messages.
2126 for test in finder.find(f, name, globs=globs):
2230 lname = '.'.join(test.name.split('.')[-1:])
2233 % (test.name, test.filename, lineno, lname, err)
2309 return self._dt_test.name
2326 name = self._dt_test.name.split('.')
2327 return "%s (%s)" % (name[-1], '.'.join(name[:-1]))
2332 return "Doctest: " + self._dt_test.name
2365 is raised showing the name of the file containing the test and a
2369 can be either a module or a module name.
2424 return '_'.join(self._dt_test.name.split('.'))
2431 % (self._dt_test.name, self._dt_test.filename, err)
2454 name = os.path.basename(path)
2457 test = parser.get_doctest(doc, globs, name, path, 0)
2484 A Python package or the name of a Python package whose directory
2615 def testsource(module, name):
2618 Provide the module (or dotted name of the module) containing the
2619 test to be debugged and the name (within the module) of the object
2624 test = [t for t in tests if t.name == name]
2626 raise ValueError(name, "not found in tests")
2656 def debug(module, name, pm=False):
2659 Provide the module (or dotted name of the module) containing the
2660 test to be debugged and the name (within the module) of the object
2664 testsrc = testsource(module, name)