99import sys
1010import tempfile
1111import unittest
12+ import unittest .mock
1213
1314from boilerplates .packaging_tests import run_module
1415
@@ -184,12 +185,12 @@ def test_bad_usage(self):
184185 _LOG .info ('%s' , sio .getvalue ())
185186
186187 def test_here (self ):
187- sio = io . StringIO ()
188- with contextlib . redirect_stdout ( sio ):
189- with preserve_logger_level ( 'version_query' ):
188+ with temporarily_set_logger_level ( 'version_query' , logging . INFO ):
189+ sio = io . StringIO ()
190+ with contextlib . redirect_stdout ( sio ):
190191 run_module ('version_query' , '.' )
191- self .assertEqual (sio .getvalue ().rstrip (), query_caller ().to_str ())
192- self .assertEqual (sio .getvalue ().rstrip (), query_version_str ())
192+ self .assertEqual (sio .getvalue ().rstrip (), query_caller ().to_str ())
193+ self .assertEqual (sio .getvalue ().rstrip (), query_version_str ())
193194
194195 def test_increment_here (self ):
195196 sio = io .StringIO ()
@@ -200,9 +201,9 @@ def test_increment_here(self):
200201 query_caller ().increment (VersionComponent .Patch ).to_str ())
201202
202203 def test_predict_here (self ):
203- sio = io . StringIO ()
204- with contextlib . redirect_stdout ( sio ):
205- with preserve_logger_level ( 'version_query' ):
204+ with temporarily_set_logger_level ( 'version_query' , logging . INFO ):
205+ sio = io . StringIO ()
206+ with contextlib . redirect_stdout ( sio ):
206207 run_module ('version_query' , '-p' , '.' )
207- self .assertEqual (sio .getvalue ().rstrip (), predict_caller ().to_str ())
208- self .assertEqual (sio .getvalue ().rstrip (), predict_version_str ())
208+ self .assertEqual (sio .getvalue ().rstrip (), predict_caller ().to_str ())
209+ self .assertEqual (sio .getvalue ().rstrip (), predict_version_str ())
0 commit comments