<s> from os import linesep <EOL> from . . version import __version__ <EOL> from . . versions import ExternalVersions <EOL> from nose . tools import assert_true , assert_false <EOL> from nose . tools import assert_equal , assert_greater_equal , assert_greater <EOL> from nose . tools import assert_raises <EOL> from nose import SkipTest <EOL> from six import PY3 <EOL> if PY3 : <EOL> def cmp ( a , b ) : <EOL> return ( a > b ) - ( a < b ) <EOL> def test_external_versions_basic ( ) : <EOL> ev = ExternalVersions ( ) <EOL> assert_equal ( ev . _versions , { } ) <EOL> assert_equal ( ev [ '<STR_LIT>' ] , __version__ ) <EOL> assert_greater_equal ( ev [ '<STR_LIT>' ] , __version__ ) <EOL> assert_greater ( ev [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( list ( ev . keys ( ) ) , [ '<STR_LIT>' ] ) <EOL> assert_true ( '<STR_LIT>' in ev ) <EOL> assert_false ( '<STR_LIT>' in ev ) <EOL> assert_equal ( ev . dumps ( ) , "<STR_LIT>" % __version__ ) <EOL> assert_equal ( ev [ '<STR_LIT>' ] , None ) <EOL> assert_equal ( set ( ev . _versions . keys ( ) ) , { '<STR_LIT>' } ) <EOL> assert_equal ( ev [ '<STR_LIT>' ] , ev . UNKNOWN ) <EOL> assert_equal ( ev . _versions . get ( '<STR_LIT>' ) , ev . UNKNOWN ) <EOL> assert ( ev [ '<STR_LIT>' ] ) <EOL> assert_raises ( TypeError , cmp , ev [ '<STR_LIT>' ] , '<STR_LIT:0>' ) <EOL> assert_raises ( TypeError , assert_greater , ev [ '<STR_LIT>' ] , '<STR_LIT:0>' ) <EOL> from duecredit . tests import mod <EOL> assert_equal ( ev [ mod ] , mod . __version__ ) <EOL> versions_dict = ev . versions <EOL> versions_dict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> assert_equal ( versions_dict [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> assert_equal ( ev [ '<STR_LIT>' ] , __version__ ) <EOL> def test_external_versions_unknown ( ) : <EOL> assert_equal ( str ( ExternalVersions . UNKNOWN ) , '<STR_LIT>' ) <EOL> def test_external_versions_popular_packages ( ) : <EOL> ev = ExternalVersions ( ) <EOL> def _test_external ( modname ) : <EOL> try : <EOL> exec ( "<STR_LIT>" % modname , locals ( ) , globals ( ) ) <EOL> except ImportError : <EOL> raise SkipTest ( "<STR_LIT>" % modname ) <EOL> except Exception as e : <EOL> raise SkipTest ( "<STR_LIT>" % ( modname , e ) ) <EOL> assert ( ev [ modname ] is not ev . UNKNOWN ) <EOL> assert_greater ( ev [ modname ] , '<STR_LIT>' ) <EOL> assert_greater ( '<STR_LIT>' , ev [ modname ] ) <EOL> for modname in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) : <EOL> yield _test_external , modname <EOL> assert_false ( linesep in ev . dumps ( ) ) <EOL> assert_true ( ev . dumps ( indent = True ) . endswith ( linesep ) ) </s>
