Best Python code snippet using nose
output_checker.py
Source:output_checker.py
...8import math9# Much of this code, particularly the parts of floating point handling, is10# borrowed from the SymPy project with permission. See11# licenses/SYMPY_LICENSE.rst for the full SymPy license.12FIX = doctest.register_optionflag('FIX')13FLOAT_CMP = doctest.register_optionflag('FLOAT_CMP')14REMOTE_DATA = doctest.register_optionflag('REMOTE_DATA')15IGNORE_OUTPUT = doctest.register_optionflag('IGNORE_OUTPUT')16IGNORE_OUTPUT_3 = doctest.register_optionflag('IGNORE_OUTPUT_3')17IGNORE_WARNINGS = doctest.register_optionflag('IGNORE_WARNINGS')18SHOW_WARNINGS = doctest.register_optionflag('SHOW_WARNINGS')19# These might appear in some doctests and are used in the default pytest20# doctest plugin. This plugin doesn't actually implement these flags but this21# allows them to appear in docstrings.22ALLOW_BYTES = doctest.register_optionflag('ALLOW_BYTES')23ALLOW_UNICODE = doctest.register_optionflag('ALLOW_UNICODE')24class OutputChecker(doctest.OutputChecker):25 """26 - Removes u'' prefixes on string literals27 - Ignores the 'L' suffix on long integers28 - In Numpy dtype strings, removes the leading pipe, i.e. '|S9' ->29 'S9'. Numpy 1.7 no longer includes it in display.30 - Supports the FLOAT_CMP flag, which parses floating point values31 out of the output and compares their numerical values rather than their32 string representation. This naturally supports complex numbers as well33 (simply by comparing their real and imaginary parts separately).34 """35 rtol = 1e-0536 atol = 1e-0837 _original_output_checker = doctest.OutputChecker...
doctester.py
Source:doctester.py
...3import re4from doctest import register_optionflag5import numpy as np6from ..fixes.numpy.testing.noseclasses import NumpyDoctest, NumpyOutputChecker7IGNORE_OUTPUT = register_optionflag('IGNORE_OUTPUT')8SYMPY_EQUAL = register_optionflag('SYMPY_EQUAL')9STRIP_ARRAY_REPR = register_optionflag('STRIP_ARRAY_REPR')10NOT_EQUAL = register_optionflag('NOT_EQUAL')11FP_4DP = register_optionflag('FP_4DP')12FP_6DP = register_optionflag('FP_6DP')13FP_REG = re.compile(r'(?<![0-9a-zA-Z_.])'14 r'(\d+\.\d+)'15 r'(e[+-]?\d+)?'16 r'(?![0-9a-zA-Z_.])')17def round_numbers(in_str, precision):18 """ Replace fp numbers in `in_str` with numbers rounded to `precision`19 Parameters20 ----------21 in_str : str22 string possibly containing floating point numbers23 precision : int24 number of decimal places to round to25 Returns26 -------...
outputchecker.py
Source:outputchecker.py
...31 def __init__(self, doctest=pythondoctest, patterns=()):32 RENormalizing.__init__(self, patterns)33 self.doctest = doctest34 # make sure these optionflags are registered35 doctest.register_optionflag('PARSE_HTML')36 doctest.register_optionflag('PARSE_XML')37 doctest.register_optionflag('NOPARSE_MARKUP')38 def _looks_like_markup(self, s):39 s = s.replace('<BLANKLINE>', '\n').strip()40 return (s.startswith('<')41 and not self._repr_re.search(s))42 def text_compare(self, want, got, strip):43 if want is None:44 want = ""45 if got is None:46 got = ""47 checker = self.doctest.OutputChecker()48 return checker.check_output(49 want, got, self.doctest.ELLIPSIS|self.doctest.NORMALIZE_WHITESPACE)50 def check_output(self, want, got, optionflags):51 if got == want:...
run_doctests
Source:run_doctests
...24import sys25import warnings26import glob27from doctest import DocTestRunner, register_optionflag, _test28SKIP35 = register_optionflag("SKIP35")29SKIP36 = register_optionflag("SKIP36")30SKIP37 = register_optionflag("SKIP37")31SKIP38 = register_optionflag("SKIP38")32SKIP39 = register_optionflag("SKIP39")33PY37 = sys.version_info[1] >= 734PY38 = sys.version_info[1] >= 835if sys.version_info[1] == 5:36 SKIP_THIS_VERSION = SKIP3537elif sys.version_info[1] == 6:38 SKIP_THIS_VERSION = SKIP3639elif sys.version_info[1] == 7:40 SKIP_THIS_VERSION = SKIP3741elif sys.version_info[1] == 8:42 SKIP_THIS_VERSION = SKIP3843elif sys.version_info[1] == 9:44 SKIP_THIS_VERSION = SKIP3945else:46 warnings.warn("Unrecognized Python version: %s.%s" % sys.version_info[:2])...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!