#NEWLINE# def test_requirements( self ) : #NEWLINE# #INDENT# '\n        Tests the requirements() function (the main external function of this package).\n        The purpose of this test is to test that the correct dependency extraction method is applied, NOT to\n        test the correctness of the individual dependency extraction methods.\n        ' #NEWLINE# expected0 = [ { #NEWLINE# #INDENT# 'extras' : ( ) , #NEWLINE# 'key' : 'dep2' , #NEWLINE# 'modules' : None , #NEWLINE# 'packages' : None , #NEWLINE# 'project_name' : 'dep2' , #NEWLINE# 'repo_url' : None , #NEWLINE# 'resolved' : False , #NEWLINE# 'specs' : [ ( '==' , '0.0' ) ] , #NEWLINE# 'type' : 'setuptools' , #NEWLINE# 'unsafe_name' : 'dep2' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'extras' : ( ) , #NEWLINE# 'key' : 'dep1' , #NEWLINE# 'modules' : None , #NEWLINE# 'packages' : None , #NEWLINE# 'project_name' : 'dep1' , #NEWLINE# 'repo_url' : None , #NEWLINE# 'resolved' : False , #NEWLINE# 'specs' : [ ] , #NEWLINE# 'type' : 'setuptools' , #NEWLINE# 'unsafe_name' : 'dep1' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'extras' : ( 'blah' , ) , #NEWLINE# 'key' : 'dep3' , #NEWLINE# 'modules' : None , #NEWLINE# 'packages' : None , #NEWLINE# 'project_name' : 'dep3' , #NEWLINE# 'repo_url' : None , #NEWLINE# 'resolved' : False , #NEWLINE# 'specs' : [ ( '>=' , '0.0.4' ) ] , #NEWLINE# 'type' : 'setuptools' , #NEWLINE# 'unsafe_name' : 'dep3' , #NEWLINE# #UNINDENT# } ] #NEWLINE# testcases = [ ( 'ex0' , expected0 ) , ( 'ex_nosetuppy' , exp ) , ( 'ex_norequirementstxt' , expected0 ) , ( 'ex_weirdsetuppy' , expected0 ) , ( 'ex_setuppy_prints' , expected0 ) , ( 'ex_nothing' , '<<ERROR>>' ) , ( 'ex_requirementstxtvcs' , [ { #NEWLINE# #INDENT# 'key' : 'https://code.google.com/p/foo' , #NEWLINE# 'repo_url' : 'https://code.google.com/p/foo' , #NEWLINE# 'type' : 'vcs' , #NEWLINE# 'modules' : None , #NEWLINE# 'extras' : None , #NEWLINE# 'packages' : None , #NEWLINE# 'project_name' : None , #NEWLINE# 'resolved' : False , #NEWLINE# 'specs' : None , #NEWLINE# 'unsafe_name' : None , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'key' : 'https://github.com/foo/bar' , #NEWLINE# 'repo_url' : 'https://github.com/foo/bar' , #NEWLINE# 'type' : 'vcs' , #NEWLINE# 'extras' : None , #NEWLINE# 'modules' : None , #NEWLINE# 'packages' : None , #NEWLINE# 'project_name' : None , #NEWLINE# 'resolved' : False , #NEWLINE# 'specs' : None , #NEWLINE# 'unsafe_name' : None , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'extras' : ( ) , #NEWLINE# 'key' : 'foo' , #NEWLINE# 'project_name' : 'foo' , #NEWLINE# 'type' : 'setuptools' , #NEWLINE# 'unsafe_name' : 'foo' , #NEWLINE# 'modules' : None , #NEWLINE# 'packages' : None , #NEWLINE# 'repo_url' : None , #NEWLINE# 'resolved' : False , #NEWLINE# 'specs' : [ ] , #NEWLINE# #UNINDENT# } ] ) ] #NEWLINE# for testcase in testcases : #NEWLINE# #INDENT# ( dir_ , exp ) = ( testcase [ 0 ] , testcase [ 1 ] ) #NEWLINE# rootdir = path . join ( testdatadir , dir_ ) #NEWLINE# ( reqs , err ) = requirements ( rootdir , resolve = False ) #NEWLINE# if ( err is not None ) : #NEWLINE# #INDENT# if ( exp != '<<ERROR>>' ) : #NEWLINE# #INDENT# print ( 'unexpected error: ' , err ) #NEWLINE# #UNINDENT# self . assertEqual ( exp , '<<ERROR>>' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertListEqual ( sorted ( exp , key = ( lambda x : x [ 'key' ] ) ) , sorted ( reqs , key = ( lambda x : x [ 'key' ] ) ) )