How to use requirements method in pandera

Best Python code snippet using pandera_python

version.py

Source:version.py Github

copy

Full Screen

1"""2Unit tests for the stem.version.Version parsing and class.3"""4import unittest5import stem.util.system6import stem.version7from stem.version import Version8try:9 # added in python 3.310 from unittest.mock import patch11except ImportError:12 from mock import patch13TOR_VERSION_OUTPUT = """Mar 22 23:09:37.088 [notice] Tor v0.2.2.35 \14(git-73ff13ab3cc9570d). This is experimental software. Do not rely on it for \15strong anonymity. (Running on Linux i686)16Tor version 0.2.2.35 (git-73ff13ab3cc9570d)."""17class TestVersion(unittest.TestCase):18 @patch('stem.util.system.call')19 @patch.dict(stem.version.VERSION_CACHE)20 def test_get_system_tor_version(self, call_mock):21 call_mock.return_value = TOR_VERSION_OUTPUT.splitlines()22 version = stem.version.get_system_tor_version()23 self.assert_versions_match(version, 0, 2, 2, 35, None, 'git-73ff13ab3cc9570d')24 self.assertEqual('73ff13ab3cc9570d', version.git_commit)25 call_mock.assert_called_once_with('tor --version')26 self.assertEqual({'tor': version}, stem.version.VERSION_CACHE)27 def test_parsing(self):28 """29 Tests parsing by the Version class constructor.30 """31 # valid versions with various number of compontents to the version32 version = Version('0.1.2.3-tag')33 self.assert_versions_match(version, 0, 1, 2, 3, 'tag', None)34 version = Version('0.1.2.3')35 self.assert_versions_match(version, 0, 1, 2, 3, None, None)36 version = Version('0.1.2-tag')37 self.assert_versions_match(version, 0, 1, 2, None, 'tag', None)38 version = Version('0.1.2')39 self.assert_versions_match(version, 0, 1, 2, None, None, None)40 # checks an empty tag41 version = Version('0.1.2.3-')42 self.assert_versions_match(version, 0, 1, 2, 3, '', None)43 version = Version('0.1.2-')44 self.assert_versions_match(version, 0, 1, 2, None, '', None)45 # check with extra informaton46 version = Version('0.1.2.3-tag (git-73ff13ab3cc9570d)')47 self.assert_versions_match(version, 0, 1, 2, 3, 'tag', 'git-73ff13ab3cc9570d')48 self.assertEqual('73ff13ab3cc9570d', version.git_commit)49 version = Version('0.1.2.3-tag ()')50 self.assert_versions_match(version, 0, 1, 2, 3, 'tag', '')51 version = Version('0.1.2 (git-73ff13ab3cc9570d)')52 self.assert_versions_match(version, 0, 1, 2, None, None, 'git-73ff13ab3cc9570d')53 # checks invalid version strings54 self.assertRaises(ValueError, stem.version.Version, '')55 self.assertRaises(ValueError, stem.version.Version, '1.2.3.4nodash')56 self.assertRaises(ValueError, stem.version.Version, '1.2.3.a')57 self.assertRaises(ValueError, stem.version.Version, '1.2.a.4')58 self.assertRaises(ValueError, stem.version.Version, '1x2x3x4')59 self.assertRaises(ValueError, stem.version.Version, '12.3')60 self.assertRaises(ValueError, stem.version.Version, '1.-2.3')61 def test_comparison(self):62 """63 Tests comparision between Version instances.64 """65 # check for basic incrementing in each portion66 self.assert_version_is_greater('1.1.2.3-tag', '0.1.2.3-tag')67 self.assert_version_is_greater('0.2.2.3-tag', '0.1.2.3-tag')68 self.assert_version_is_greater('0.1.3.3-tag', '0.1.2.3-tag')69 self.assert_version_is_greater('0.1.2.4-tag', '0.1.2.3-tag')70 self.assert_version_is_greater('0.1.2.3-ugg', '0.1.2.3-tag')71 self.assert_version_is_equal('0.1.2.3-tag', '0.1.2.3-tag')72 # check with common tags73 self.assert_version_is_greater('0.1.2.3-beta', '0.1.2.3-alpha')74 self.assert_version_is_greater('0.1.2.3-rc', '0.1.2.3-beta')75 # checks that a missing patch level equals zero76 self.assert_version_is_equal('0.1.2', '0.1.2.0')77 self.assert_version_is_equal('0.1.2-tag', '0.1.2.0-tag')78 # checks for missing patch or status79 self.assert_version_is_greater('0.1.2.3-tag', '0.1.2.3')80 self.assert_version_is_greater('0.1.2.3-tag', '0.1.2-tag')81 self.assert_version_is_greater('0.1.2.3-tag', '0.1.2')82 self.assert_version_is_equal('0.1.2.3', '0.1.2.3')83 self.assert_version_is_equal('0.1.2', '0.1.2')84 def test_nonversion_comparison(self):85 """86 Checks that we can be compared with other types.87 In python 3 on only equality comparisons work, greater than and less than88 comparisons result in a TypeError.89 """90 test_version = Version('0.1.2.3')91 self.assertNotEqual(test_version, None)92 self.assertNotEqual(test_version, 5)93 def test_string(self):94 """95 Tests the Version -> string conversion.96 """97 # checks conversion with various numbers of arguments98 self.assert_string_matches('0.1.2.3-tag')99 self.assert_string_matches('0.1.2.3')100 self.assert_string_matches('0.1.2')101 def test_requirements_greater_than(self):102 """103 Checks a VersionRequirements with a single greater_than rule.104 """105 requirements = stem.version._VersionRequirements()106 requirements.greater_than(Version('0.2.2.36'))107 self.assertTrue(Version('0.2.2.36') >= requirements)108 self.assertTrue(Version('0.2.2.37') >= requirements)109 self.assertTrue(Version('0.2.3.36') >= requirements)110 self.assertFalse(Version('0.2.2.35') >= requirements)111 self.assertFalse(Version('0.2.1.38') >= requirements)112 requirements = stem.version._VersionRequirements()113 requirements.greater_than(Version('0.2.2.36'), False)114 self.assertFalse(Version('0.2.2.35') >= requirements)115 self.assertFalse(Version('0.2.2.36') >= requirements)116 self.assertTrue(Version('0.2.2.37') >= requirements)117 def test_requirements_less_than(self):118 """119 Checks a VersionRequirements with a single less_than rule.120 """121 requirements = stem.version._VersionRequirements()122 requirements.less_than(Version('0.2.2.36'))123 self.assertTrue(Version('0.2.2.36') >= requirements)124 self.assertTrue(Version('0.2.2.35') >= requirements)125 self.assertTrue(Version('0.2.1.38') >= requirements)126 self.assertFalse(Version('0.2.2.37') >= requirements)127 self.assertFalse(Version('0.2.3.36') >= requirements)128 requirements = stem.version._VersionRequirements()129 requirements.less_than(Version('0.2.2.36'), False)130 self.assertFalse(Version('0.2.2.37') >= requirements)131 self.assertFalse(Version('0.2.2.36') >= requirements)132 self.assertTrue(Version('0.2.2.35') >= requirements)133 def test_requirements_in_range(self):134 """135 Checks a VersionRequirements with a single in_range rule.136 """137 requirements = stem.version._VersionRequirements()138 requirements.in_range(Version('0.2.2.36'), Version('0.2.2.38'))139 self.assertFalse(Version('0.2.2.35') >= requirements)140 self.assertTrue(Version('0.2.2.36') >= requirements)141 self.assertTrue(Version('0.2.2.37') >= requirements)142 self.assertFalse(Version('0.2.2.38') >= requirements)143 # rule for 'anything in the 0.2.2.x series'144 requirements = stem.version._VersionRequirements()145 requirements.in_range(Version('0.2.2.0'), Version('0.2.3.0'))146 for index in range(0, 100):147 self.assertTrue(Version('0.2.2.%i' % index) >= requirements)148 def test_requirements_multiple_rules(self):149 """150 Checks a VersionRequirements is the logical 'or' when it has multiple rules.151 """152 # rule to say 'anything but the 0.2.2.x series'153 requirements = stem.version._VersionRequirements()154 requirements.greater_than(Version('0.2.3.0'))155 requirements.less_than(Version('0.2.2.0'), False)156 self.assertTrue(Version('0.2.3.0') >= requirements)157 self.assertFalse(Version('0.2.2.0') >= requirements)158 for index in range(0, 100):159 self.assertFalse(Version('0.2.2.%i' % index) >= requirements)160 def assert_versions_match(self, version, major, minor, micro, patch, status, extra):161 """162 Asserts that the values for a types.Version instance match the given163 values.164 """165 self.assertEqual(major, version.major)166 self.assertEqual(minor, version.minor)167 self.assertEqual(micro, version.micro)168 self.assertEqual(patch, version.patch)169 self.assertEqual(status, version.status)170 self.assertEqual(extra, version.extra)171 if extra is None:172 self.assertEqual(None, version.git_commit)173 def assert_version_is_greater(self, first_version, second_version):174 """175 Asserts that the parsed version of the first version is greate than the176 second (also checking the inverse).177 """178 version1 = Version(first_version)179 version2 = Version(second_version)180 self.assertEqual(version1 > version2, True)181 self.assertEqual(version1 < version2, False)182 def assert_version_is_equal(self, first_version, second_version):183 """184 Asserts that the parsed version of the first version equals the second.185 """186 version1 = Version(first_version)187 version2 = Version(second_version)188 self.assertEqual(version1, version2)189 def assert_string_matches(self, version):190 """191 Parses the given version string then checks that its string representation192 matches the input.193 """...

Full Screen

Full Screen

python_stack.py

Source:python_stack.py Github

copy

Full Screen

...39 if requirements_format is not None:40 self.requirements_format = requirements_format41 self.requirements_lock = requirements_lock42 @property43 def requirements(self):44 """Gets the requirements of this PythonStack. # noqa: E50145 :return: The requirements of this PythonStack. # noqa: E50146 :rtype: RequirementsDef47 """48 return self._requirements49 @requirements.setter50 def requirements(self, requirements):51 """Sets the requirements of this PythonStack.52 :param requirements: The requirements of this PythonStack. # noqa: E50153 :type: RequirementsDef54 """55 if requirements is None:56 raise ValueError("Invalid value for `requirements`, must not be `None`") # noqa: E50157 self._requirements = requirements58 @property59 def requirements_format(self):60 """Gets the requirements_format of this PythonStack. # noqa: E50161 Lockfile format - defaults to pipenv if not explicitly specified # noqa: E50162 :return: The requirements_format of this PythonStack. # noqa: E50163 :rtype: list[str]64 """...

Full Screen

Full Screen

analysis_result_response_result_aicoeci.py

Source:analysis_result_response_result_aicoeci.py Github

copy

Full Screen

...34 self.discriminator = None35 self.requirements = requirements36 self.requirements_lock = requirements_lock37 @property38 def requirements(self):39 """Gets the requirements of this AnalysisResultResponseResultAicoeci. # noqa: E50140 :return: The requirements of this AnalysisResultResponseResultAicoeci. # noqa: E50141 :rtype: RequirementsDef42 """43 return self._requirements44 @requirements.setter45 def requirements(self, requirements):46 """Sets the requirements of this AnalysisResultResponseResultAicoeci.47 :param requirements: The requirements of this AnalysisResultResponseResultAicoeci. # noqa: E50148 :type: RequirementsDef49 """50 if requirements is None:51 raise ValueError("Invalid value for `requirements`, must not be `None`") # noqa: E50152 self._requirements = requirements53 @property54 def requirements_lock(self):55 """Gets the requirements_lock of this AnalysisResultResponseResultAicoeci. # noqa: E50156 :return: The requirements_lock of this AnalysisResultResponseResultAicoeci. # noqa: E50157 :rtype: RequirementsLockDef58 """59 return self._requirements_lock...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful