<s> from contextlib import contextmanager <EOL> import os <EOL> import sys <EOL> from django . test import TestCase <EOL> from django . test . runner import DiscoverRunner <EOL> from django . utils . unittest import expectedFailure <EOL> try : <EOL> import unittest2 <EOL> except ImportError : <EOL> unittest2 = None <EOL> def expectedFailureIf ( condition ) : <EOL> """<STR_LIT>""" <EOL> if condition : <EOL> return expectedFailure <EOL> return lambda func : func <EOL> class DiscoverRunnerTest ( TestCase ) : <EOL> def test_dotted_test_module ( self ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:3> ) <EOL> def test_dotted_test_class_vanilla_unittest ( self ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:1> ) <EOL> def test_dotted_test_class_unittest2 ( self ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:1> ) <EOL> def test_dotted_test_class_django_testcase ( self ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:1> ) <EOL> @ expectedFailureIf ( sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) and unittest2 ) <EOL> def test_dotted_test_method_vanilla_unittest ( self ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:1> ) <EOL> def test_dotted_test_method_unittest2 ( self ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:1> ) <EOL> def test_dotted_test_method_django_testcase ( self ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:1> ) <EOL> def test_pattern ( self ) : <EOL> count = DiscoverRunner ( <EOL> pattern = "<STR_LIT>" , <EOL> ) . build_suite ( [ "<STR_LIT>" ] ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:1> ) <EOL> def test_file_path ( self ) : <EOL> @ contextmanager <EOL> def change_cwd_to_tests ( ) : <EOL> """<STR_LIT>""" <EOL> current_dir = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> tests_dir = os . path . join ( current_dir , '<STR_LIT:..>' ) <EOL> old_cwd = os . getcwd ( ) <EOL> os . chdir ( tests_dir ) <EOL> yield <EOL> os . chdir ( old_cwd ) <EOL> with change_cwd_to_tests ( ) : <EOL> count = DiscoverRunner ( ) . build_suite ( <EOL> [ "<STR_LIT>" ] , <EOL> ) . countTestCases ( ) <EOL> self . assertEqual ( count , <NUM_LIT:4> ) </s>
