2929from apache_beam .examples .complete import tfidf
3030from apache_beam .testing .test_pipeline import TestPipeline
3131from apache_beam .testing .test_utils import create_file
32- from apache_beam .testing .test_utils import read_gcs_output_file
33-
34- # Protect against environments where gcsio library is not available.
35- try :
36- from apache_beam .io .gcp import gcsio
37- except ImportError :
38- gcsio = None
32+ from apache_beam .testing .test_utils import read_files_from_pattern
3933
4034EXPECTED_RESULTS = set ([
4135 ('ghi' , '1.txt' , 0.3662040962227032 ), ('abc' , '1.txt' , 0.0 ),
4640EXPECTED_LINE_RE = r'\(u?\'([a-z]*)\', \(\'.*([0-9]\.txt)\', (.*)\)\)'
4741
4842
49- @unittest .skipIf (gcsio is None , 'GCP dependencies are not installed' )
5043class TfIdfIT (unittest .TestCase ):
5144 @pytest .mark .examples_postcommit
5245 def test_basics (self ):
@@ -60,14 +53,14 @@ def test_basics(self):
6053 create_file ('/' .join ([input_folder , '3.txt' ]), 'abc' )
6154 output = '/' .join ([temp_location , str (uuid .uuid4 ()), 'result' ])
6255
63- extra_opts = {'uris' : input_folder , 'output' : output }
56+ extra_opts = {'uris' : '%s/**' % input_folder , 'output' : output }
6457 tfidf .run (
6558 test_pipeline .get_full_options_as_args (** extra_opts ),
6659 save_main_session = False )
6760
6861 # Parse result file and compare.
6962 results = []
70- lines = read_gcs_output_file ( output ).splitlines ()
63+ lines = read_files_from_pattern ( '%s*' % output ).splitlines ()
7164 for line in lines :
7265 match = re .search (EXPECTED_LINE_RE , line )
7366 logging .info ('Result line: %s' , line )
0 commit comments