File: conftest.py

package info (click to toggle)
python-hpack 4.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 444 kB
  • sloc: python: 5,866; makefile: 25
file content (48 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download | duplicates (18)
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
46
47
48
# -*- coding: utf-8 -*-
import pytest
import os
import json
import sys

from hypothesis.strategies import text

if sys.version_info[0] == 2:
    from codecs import open

# We need to grab one text example from hypothesis to prime its cache.
text().example()

# This pair of generator expressions are pretty lame, but building lists is a
# bad idea as I plan to have a substantial number of tests here.
story_directories = (
    os.path.join('test/test_fixtures', d)
    for d in os.listdir('test/test_fixtures')
)
story_files = (
    os.path.join(storydir, name)
    for storydir in story_directories
    for name in os.listdir(storydir)
    if 'raw-data' not in storydir
)
raw_story_files = (
    os.path.join('test/test_fixtures/raw-data', name)
    for name in os.listdir('test/test_fixtures/raw-data')
)


@pytest.fixture(scope='class', params=story_files)
def story(request):
    """
    Provides a detailed HPACK story to test with.
    """
    with open(request.param, 'r', encoding='utf-8') as f:
        return json.load(f)


@pytest.fixture(scope='class', params=raw_story_files)
def raw_story(request):
    """
    Provides a detailed HPACK story to test the encoder with.
    """
    with open(request.param, 'r', encoding='utf-8') as f:
        return json.load(f)