<s> import os . path , sys , pprint <EOL> import token , symbol <EOL> import libpry <EOL> import libpry . coverage <EOL> import testUnit <EOL> class uCoverage ( libpry . AutoTree ) : <EOL> def setUp ( self ) : <EOL> self . cov = libpry . coverage . Coverage ( "<STR_LIT>" ) <EOL> def test_run ( self ) : <EOL> self . cov . start ( ) <EOL> reload ( testUnit . mymod ) <EOL> testUnit . mymod . run ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . cov . stop ( ) <EOL> f = self . cov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] <EOL> assert f . executed == set ( [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:8> , <NUM_LIT:12> ] ) <EOL> def test_docstrings ( self ) : <EOL> self . cov . start ( ) <EOL> import testUnit . docstrings <EOL> testUnit . docstrings . foo ( ) <EOL> self . cov . stop ( ) <EOL> pth = os . path . abspath ( "<STR_LIT>" ) <EOL> f = self . cov . fileDict [ os . path . abspath ( pth ) ] <EOL> assert not f . notExecuted <EOL> def test_longfuncsig ( self ) : <EOL> self . cov . start ( ) <EOL> import testUnit . longfuncsig <EOL> testUnit . longfuncsig . foo ( <NUM_LIT:1> ) <EOL> f = testUnit . longfuncsig . Foo ( ) <EOL> f . foo ( <NUM_LIT:1> ) <EOL> self . cov . stop ( ) <EOL> pth = os . path . abspath ( "<STR_LIT>" ) <EOL> f = self . cov . fileDict [ os . path . abspath ( pth ) ] <EOL> assert f . executed == f . executable <EOL> def test_longjump ( self ) : <EOL> self . cov . start ( ) <EOL> import testUnit . longjump <EOL> testUnit . longjump . foo ( ) <EOL> self . cov . stop ( ) <EOL> pth = os . path . abspath ( "<STR_LIT>" ) <EOL> f = self . cov . fileDict [ os . path . abspath ( pth ) ] <EOL> assert not f . notExecuted <EOL> def test_coveragePath ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cov . start ( ) <EOL> import testUnit . mymod <EOL> testUnit . mymod . coveragePath ( ) <EOL> self . cov . stop ( ) <EOL> f = self . cov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] <EOL> assert len ( f . executed ) <= <NUM_LIT:2> <EOL> def test_excludePath ( self ) : <EOL> mycov = libpry . coverage . Coverage ( "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> mycov . start ( ) <EOL> import testUnit . mymod , testUnit . mymod2 <EOL> testUnit . mymod . coveragePath ( ) <EOL> testUnit . mymod2 . coveragePath ( ) <EOL> mycov . stop ( ) <EOL> total = mycov . getGlobalStats ( ) [ "<STR_LIT>" ] <EOL> assert total == <NUM_LIT:2> <EOL> assert mycov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] . executed <EOL> def test_matching ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cov . start ( ) <EOL> import testUnit . matching <EOL> testUnit . matching . foo ( <NUM_LIT:1> ) <EOL> testUnit . matching . foo ( <NUM_LIT:0> ) <EOL> self . cov . stop ( ) <EOL> f = self . cov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] <EOL> assert f . executable == f . executed <EOL> def test_getStats ( self ) : <EOL> self . cov . start ( ) <EOL> import testUnit . getStats , testUnit . getRanges <EOL> reload ( testUnit . getRanges ) <EOL> testUnit . getStats . foo ( ) <EOL> testUnit . getRanges . foo ( ) <EOL> self . cov . stop ( ) <EOL> f = self . cov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] <EOL> assert f . numExecutable == <NUM_LIT:4> <EOL> assert f . numExecuted == <NUM_LIT:3> <EOL> assert f . percentage == <NUM_LIT> <EOL> assert f . notExecutedRanges == [ <NUM_LIT:5> ] <EOL> f = self . cov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] <EOL> assert f . numExecutable == <NUM_LIT:12> <EOL> assert f . notExecutedRanges == [ <NUM_LIT:6> , <NUM_LIT:9> , <NUM_LIT> ] <EOL> assert f . numExecuted == <NUM_LIT:9> <EOL> assert f . percentage == <NUM_LIT> <EOL> def test_getGlobalStats2 ( self ) : <EOL> """<STR_LIT>""" <EOL> mycov = libpry . coverage . Coverage ( "<STR_LIT>" ) <EOL> mycov . start ( ) <EOL> import testUnit . getGlobalStats2 <EOL> testUnit . getGlobalStats2 . foo ( ) <EOL> mycov . stop ( ) <EOL> def test_getGlobalStats ( self ) : <EOL> mycov = libpry . coverage . Coverage ( "<STR_LIT>" ) <EOL> mycov . start ( ) <EOL> reload ( testUnit . getGlobalStats ) <EOL> testUnit . getGlobalStats . foo ( ) <EOL> mycov . stop ( ) <EOL> expected = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:4> <EOL> } <EOL> x = mycov . getGlobalStats ( ) <EOL> assert x == expected <EOL> def test_getRanges ( self ) : <EOL> self . cov . start ( ) <EOL> import testUnit . getRanges <EOL> testUnit . getRanges . foo ( ) <EOL> self . cov . stop ( ) <EOL> f = self . cov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] <EOL> expected = [ <NUM_LIT:6> , <NUM_LIT:9> , <NUM_LIT> ] <EOL> assert f . notExecutedRanges == expected <EOL> def test_getAnnotation ( self ) : <EOL> self . cov . start ( ) <EOL> import testUnit . getAnnotation <EOL> testUnit . getAnnotation . foo ( ) <EOL> self . cov . stop ( ) <EOL> f = self . cov . fileDict [ os . path . abspath ( "<STR_LIT>" ) ] <EOL> annotatedFile = open ( "<STR_LIT>" ) . read ( ) <EOL> assert f . getAnnotation ( ) == annotatedFile <EOL> def test_coverageReport ( self ) : <EOL> self . cov . start ( ) <EOL> import testUnit . getGlobalStats <EOL> testUnit . getGlobalStats . foo ( ) <EOL> self . cov . stop ( ) <EOL> self . cov . coverageReport ( ) <EOL> tests = [ <EOL> uCoverage ( ) <EOL> ] </s>
