hbmartin commited on
Commit
3f026d1
·
1 Parent(s): b8d2d59

use open_mock variable name

Browse files
Files changed (2) hide show
  1. .deepsource.toml +1 -1
  2. tests/test_captions.py +6 -6
.deepsource.toml CHANGED
@@ -1,7 +1,7 @@
1
  version = 1
2
 
3
  test_patterns = [
4
- "*/tests/**"
5
  ]
6
 
7
  exclude_patterns = [
 
1
  version = 1
2
 
3
  test_patterns = [
4
+ "tests/**"
5
  ]
6
 
7
  exclude_patterns = [
tests/test_captions.py CHANGED
@@ -46,38 +46,38 @@ def test_caption_query_get_by_language_code_when_not_exists():
46
 
47
  @mock.patch("pytube.captions.Caption.generate_srt_captions")
48
  def test_download(srt):
49
- m = mock_open()
50
  with patch("builtins.open", m):
51
  srt.return_value = ""
52
  caption = Caption(
53
  {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
54
  )
55
  caption.download("title")
56
- assert m.call_args_list[0][0][0].split("/")[-1] == "title (en).srt"
57
 
58
 
59
  @mock.patch("pytube.captions.Caption.generate_srt_captions")
60
  def test_download_with_prefix(srt):
61
- m = mock_open()
62
  with patch("builtins.open", m):
63
  srt.return_value = ""
64
  caption = Caption(
65
  {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
66
  )
67
  caption.download("title", filename_prefix="1 ")
68
- assert m.call_args_list[0][0][0].split("/")[-1] == "1 title (en).srt"
69
 
70
 
71
  @mock.patch("pytube.captions.Caption.xml_captions")
72
  def test_download_xml_and_trim_extension(xml):
73
- m = mock_open()
74
  with patch("builtins.open", m):
75
  xml.return_value = ""
76
  caption = Caption(
77
  {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
78
  )
79
  caption.download("title.xml", srt=False)
80
- assert m.call_args_list[0][0][0].split("/")[-1] == "title (en).xml"
81
 
82
 
83
  def test_repr():
 
46
 
47
  @mock.patch("pytube.captions.Caption.generate_srt_captions")
48
  def test_download(srt):
49
+ open_mock = mock_open()
50
  with patch("builtins.open", m):
51
  srt.return_value = ""
52
  caption = Caption(
53
  {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
54
  )
55
  caption.download("title")
56
+ assert open_mock.call_args_list[0][0][0].split("/")[-1] == "title (en).srt"
57
 
58
 
59
  @mock.patch("pytube.captions.Caption.generate_srt_captions")
60
  def test_download_with_prefix(srt):
61
+ open_mock = mock_open()
62
  with patch("builtins.open", m):
63
  srt.return_value = ""
64
  caption = Caption(
65
  {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
66
  )
67
  caption.download("title", filename_prefix="1 ")
68
+ assert open_mock.call_args_list[0][0][0].split("/")[-1] == "1 title (en).srt"
69
 
70
 
71
  @mock.patch("pytube.captions.Caption.xml_captions")
72
  def test_download_xml_and_trim_extension(xml):
73
+ open_mock = mock_open()
74
  with patch("builtins.open", m):
75
  xml.return_value = ""
76
  caption = Caption(
77
  {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en"}
78
  )
79
  caption.download("title.xml", srt=False)
80
+ assert open_mock.call_args_list[0][0][0].split("/")[-1] == "title (en).xml"
81
 
82
 
83
  def test_repr():