def test_parse_requirement_with_hash_option(self): reqs, links = pkg_utils.parse_requirement_lines(['git+https://github.com/opt/req1.git#egg=req1-1.2.3&sha256=44ddfb12']) self.assertEqual(reqs, ['req1']) self.assertEqual(links, ['git+https://github.com/opt/req1.git#egg=req1-1.2.3&sha256=44ddfb12']) reqs, links = pkg_utils.parse_requirement_lines(['git+https://github.com/opt/req1.git#egg=req1-1.2.3&sha256=44ddfb12 >= 1.1.2']) self.assertEqual(reqs, ['req1 >= 1.1.2']) self.assertEqual(links, ['git+https://github.com/opt/req1.git#egg=req1-1.2.3&sha256=44ddfb12'])
def test_parse_requirement_with_subdirectory(self): reqs, links = pkg_utils.parse_requirement_lines(['git+https://github.com/opt/req1.git#egg=req1-1.1.2&subdirectory=subdir']) self.assertEqual(reqs, ['req1']) self.assertEqual(links, ['git+https://github.com/opt/req1.git#egg=req1-1.1.2&subdirectory=subdir']) reqs, links = pkg_utils.parse_requirement_lines(['git+https://github.com/opt/req1.git#egg=req1-1.1.2&subdirectory=subdir > 1.1.2']) self.assertEqual(reqs, ['req1 > 1.1.2']) self.assertEqual(links, ['git+https://github.com/opt/req1.git#egg=req1-1.1.2&subdirectory=subdir'])
def test_parse_requirement_without_version_hint(self): with self.assertRaisesRegex(ValueError, 'Version hints must be provided'): pkg_utils.parse_requirement_lines(['git+https://github.com/opt/req1.git#egg=req1'])
def test_parse_requirement_local_file_option(self): with self.assertRaisesRegex(ValueError, 'Local file option is not supported'): pkg_utils.parse_requirement_lines(['local_dir/req1.git#egg=req1'])
def test_parse_requirement_with_editable_option(self): with self.assertRaisesRegex(ValueError, 'Editable option is not supported'): pkg_utils.parse_requirement_lines(['-e git+https://github.com/opt/req1.git#egg=req1'])
def test_parse_requirement_invalid_name(self): with self.assertRaisesRegex(ValueError, 'Dependency could not be parsed:'): pkg_utils.parse_requirement_lines(['git+https://github.com/opt/req1.git#egg=req-ui-r-ment'])
def test_parse_requirement_invalid_comment_before_egg(self): with self.assertRaisesRegex(ValueError, ''): pkg_utils.parse_requirement_lines(['req2 #git+https://github.com/opt/req1.git#egg=req1'])