Best Python code snippet using prospector_python
test_watcher.py
Source:test_watcher.py
1import mock2from tvrenamer.core import watcher3from tvrenamer.tests import base4class WatcherTests(base.BaseTest):5 def test_is_valid_extension(self):6 valids = ['.avi', '.mp4', '.mkv', 'mpg']7 self.CONF.set_override('valid_extensions', valids)8 self.assertTrue(watcher._is_valid_extension('.avi'))9 self.assertTrue(watcher._is_valid_extension('.mp4'))10 self.assertTrue(watcher._is_valid_extension('.mkv'))11 self.assertTrue(watcher._is_valid_extension('.mpg'))12 self.assertFalse(watcher._is_valid_extension('.mov'))13 self.assertFalse(watcher._is_valid_extension(''))14 self.assertFalse(watcher._is_valid_extension(None))15 self.CONF.set_override('valid_extensions', [])16 self.assertTrue(watcher._is_valid_extension('.mov'))17 self.CONF.set_override('valid_extensions', None)18 self.assertTrue(watcher._is_valid_extension('.mov'))19 def test_is_blacklisted_filename(self):20 self.CONF.set_override('filename_blacklist', None)21 self.assertFalse(watcher._is_blacklisted_filename(None))22 blacklist = ['readme.txt', '.DS_File']23 self.CONF.set_override('filename_blacklist', blacklist)24 self.assertFalse(watcher._is_blacklisted_filename('/tmp/test.avi'))25 self.assertTrue(watcher._is_blacklisted_filename('/tmp/.DS_File'))26 blacklist = [{'full_path': '',27 'exclude_extension': False,28 'is_regex': False,29 'match': '.DS_File'}]30 self.CONF.set_override('filename_blacklist', blacklist)31 self.assertTrue(watcher._is_blacklisted_filename('/tmp/.DS_File'))32 blacklist = [{'full_path': '',...
test_package_installer.py
Source:test_package_installer.py
...76 self.assertEqual(result, INSTALL_FAILURE)77 else:78 self.assertEqual(result, INSTALL_SUCCESS)79 def test_extract_ext_success(self):80 self.assertEquals(_is_valid_extension("abc.deb"), True)81 self.assertEquals(_is_valid_extension("abc.rpm"), True)82 def test_extract_ext_fail(self):83 self.assertEquals(_is_valid_extension("abc.abc"), False)84if __name__ == '__main__':...
test_command_parser.py
Source:test_command_parser.py
...38 assert CommandParser._is_valid_integer('15')39 def test_is_valid_integer_exception_contains_invalid_characters(self):40 with pytest.raises(argparse.ArgumentTypeError):41 CommandParser._is_valid_integer('115d5')42 def test_is_valid_extension(self, monkeypatch):43 def mockreturn(file):44 return True45 monkeypatch.setattr(CommandParser, '_is_valid_file', mockreturn)46 assert CommandParser._is_valid_extension([".fastq"])('/Path/to/test.fastq')47 def test_is_valid_extension_multiple(self, monkeypatch):48 def mockreturn(file):49 return True50 monkeypatch.setattr(CommandParser, '_is_valid_file', mockreturn)51 assert CommandParser._is_valid_extension(['fastq', 'fastq.gz'])('test.fastq.gz')52 def test_is_not_valid_extension(self, monkeypatch):53 def mockreturn(file):54 return True55 monkeypatch.setattr(CommandParser, '_is_valid_file', mockreturn)56 with pytest.raises(argparse.ArgumentTypeError):57 assert CommandParser._is_valid_extension([".txt"])('/Path/to/test.fastq')58 def test_is_not_valid_extension_multiple(self, monkeypatch):59 def mockreturn(file):60 return True61 monkeypatch.setattr(CommandParser, '_is_valid_file', mockreturn)62 with pytest.raises(argparse.ArgumentTypeError):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!