barunsaha commited on
Commit
91dea06
·
1 Parent(s): 0a33905

Patch tokenizer in the unit tests

Browse files
Files changed (2) hide show
  1. tests/unit/test_cli.py +15 -11
  2. tests/unit/test_core.py +13 -3
tests/unit/test_cli.py CHANGED
@@ -1,5 +1,5 @@
1
  """
2
- Unit tests for the cli module.
3
  """
4
  import argparse
5
  import sys
@@ -8,16 +8,20 @@ from unittest.mock import patch, MagicMock
8
 
9
  import pytest
10
 
11
- from slidedeckai.cli import (
12
- group_models_by_provider,
13
- format_models_as_bullets,
14
- CustomArgumentParser,
15
- CustomHelpFormatter,
16
- format_models_list,
17
- format_model_help,
18
- main
19
- )
20
- from slidedeckai.global_config import GlobalConfig
 
 
 
 
21
 
22
 
23
  def test_group_models_by_provider():
 
1
  """
2
+ Unit tests for the CLI of SlideDeck AI.
3
  """
4
  import argparse
5
  import sys
 
8
 
9
  import pytest
10
 
11
+ # Apply BertTokenizer patch before importing anything that might use it
12
+ from .test_utils import patch_bert_tokenizer
13
+
14
+ with patch('transformers.BertTokenizer', patch_bert_tokenizer()):
15
+ from slidedeckai.cli import (
16
+ group_models_by_provider,
17
+ format_models_as_bullets,
18
+ CustomArgumentParser,
19
+ CustomHelpFormatter,
20
+ format_models_list,
21
+ format_model_help,
22
+ main
23
+ )
24
+ from slidedeckai.global_config import GlobalConfig
25
 
26
 
27
  def test_group_models_by_provider():
tests/unit/test_core.py CHANGED
@@ -1,13 +1,23 @@
1
  """
2
- Unit tests for the core module.
3
  """
4
  import os
5
  from pathlib import Path
6
  from unittest import mock
 
 
7
  import pytest
8
 
9
- from slidedeckai.core import SlideDeckAI, _process_llm_chunk, _stream_llm_response
10
- from .test_utils import get_mock_llm, get_mock_llm_response, MockStreamResponse
 
 
 
 
 
 
 
 
11
 
12
 
13
  @pytest.fixture
 
1
  """
2
+ Unit tests for the core module of SlideDeck AI.
3
  """
4
  import os
5
  from pathlib import Path
6
  from unittest import mock
7
+ from unittest.mock import patch
8
+
9
  import pytest
10
 
11
+ # Apply BertTokenizer patch before importing anything that might use it
12
+ from .test_utils import (
13
+ get_mock_llm,
14
+ get_mock_llm_response,
15
+ MockStreamResponse,
16
+ patch_bert_tokenizer
17
+ )
18
+
19
+ with patch('transformers.BertTokenizer', patch_bert_tokenizer()):
20
+ from slidedeckai.core import SlideDeckAI, _process_llm_chunk, _stream_llm_response
21
 
22
 
23
  @pytest.fixture