Debian Codegraph @

testing/web-platform/tests/tools/third_party/hpack/test/conftest.py

raw
1 # -*- coding: utf-8 -*-
2 import pytest
3 import os
4 import json
5 import sys
6
7 from hypothesis.strategies import text
8
9 if sys.version_info[0] == 2:
10 from codecs import open
11
12 # We need to grab one text example from hypothesis to prime its cache.
13 text().example()
14
15 # This pair of generator expressions are pretty lame, but building lists is a
16 # bad idea as I plan to have a substantial number of tests here.
17 story_directories = (
18 os.path.join('test/test_fixtures', d)
19 for d in os.listdir('test/test_fixtures')
20 )
21 story_files = (
22 os.path.join(storydir, name)
23 for storydir in story_directories
24 for name in os.listdir(storydir)
25 if 'raw-data' not in storydir
26 )
27 raw_story_files = (
28 os.path.join('test/test_fixtures/raw-data', name)
29 for name in os.listdir('test/test_fixtures/raw-data')
30 )
31
32
33 @pytest.fixture(scope='class', params=story_files)
34 def story(request):
35 """
36 Provides a detailed HPACK story to test with.
37 """
38 with open(request.param, 'r', encoding='utf-8') as f:
39 return json.load(f)
40
41
42 @pytest.fixture(scope='class', params=raw_story_files)
43 def raw_story(request):
44 """
45 Provides a detailed HPACK story to test the encoder with.
46 """
47 with open(request.param, 'r', encoding='utf-8') as f:
48 return json.load(f)