Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

test_utils.py 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  1. import pytest
  2. from deepClassifier.utils import read_yaml
  3. from pathlib import Path
  4. from box import ConfigBox
  5. from ensure.main import EnsureError
  6. yaml_file = [
  7. "tests/data/empty.yaml",
  8. "tests/data/demo.yaml",
  9. ]
  10. def test_read_yaml_empty():
  11. with pytest.raises(ValueError):
  12. read_yaml(Path(yaml_file[0]))
  13. def test_read_yaml_return_type():
  14. respone = read_yaml(Path(yaml_file[-1]))
  15. assert isinstance(respone, ConfigBox)
  16. @pytest.mark.parametrize("path_to_yaml",yaml_file)
  17. def test_read_yaml_bad_type(path_to_yaml):
  18. with pytest.raises(EnsureError):
  19. read_yaml(path_to_yaml)
  20. class Test_read_yaml:
  21. yaml_files = [
  22. "tests/data/empty.yaml",
  23. "tests/data/demo.yaml"
  24. ]
  25. def test_read_yaml_empty(self):
  26. with pytest.raises(ValueError):
  27. read_yaml(Path(self.yaml_files[0]))
  28. def test_read_yaml_return_type(self):
  29. respone = read_yaml(Path(self.yaml_files[-1]))
  30. assert isinstance(respone, ConfigBox)
  31. @pytest.mark.parametrize("path_to_yaml", yaml_files)
  32. def test_read_yaml_bad_type(self, path_to_yaml):
  33. with pytest.raises(EnsureError):
  34. read_yaml(path_to_yaml)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...