def conanfile_txt_errors_test(self): # Valid content file_content = '''[requires} OpenCV/2.4.10@phil/stable # My requirement for CV ''' with self.assertRaisesRegexp(ConanException, "Bad syntax"): ConanFileTextLoader(file_content) file_content = '{hello}' with self.assertRaisesRegexp(ConanException, "Unexpected line"): ConanFileTextLoader(file_content)
def revision_parsing_test(self): # Valid content file_content = '''[requires] OpenCV/2.4.10@user/stable#RREV1 # My requirement for CV ''' parser = ConanFileTextLoader(file_content) exp = ['OpenCV/2.4.10@user/stable#RREV1'] self.assertEqual(parser.requirements, exp)
def conanfile_txt_errors_test(self): # Valid content file_content = '''[requires} OpenCV/2.4.10@phil/stable # My requirement for CV ''' with six.assertRaisesRegex(self, ConanException, "Bad syntax"): ConanFileTextLoader(file_content) file_content = '{hello}' with six.assertRaisesRegex(self, ConanException, "Unexpected line"): ConanFileTextLoader(file_content) file_content = '[imports]\nhello' with six.assertRaisesRegex(self, ConanException, "Invalid imports line: hello"): ConanFileTextLoader(file_content).imports_method(None) file_content = '[imports]\nbin, * -> bin @ kk=3 ' with six.assertRaisesRegex(self, ConanException, "Unknown argument kk"): ConanFileTextLoader(file_content).imports_method(None)
def plain_text_parser_test(self): # Valid content file_content = '''[requires] OpenCV/2.4.10@phil/stable # My requirement for CV OpenCV2/2.4.10@phil/stable # OpenCV3/2.4.10@phil/stable [generators] one # My generator for this two [options] OpenCV:use_python=True # Some option OpenCV:other_option=False OpenCV2:use_python2=1 OpenCV2:other_option=Cosa # ''' parser = ConanFileTextLoader(file_content) exp = ['OpenCV/2.4.10@phil/stable', 'OpenCV2/2.4.10@phil/stable', 'OpenCV3/2.4.10@phil/stable'] self.assertEquals(parser.requirements, exp)