File: microdescriptor.py

package info (click to toggle)
python-stem 1.4.1b-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 5,132 kB
  • sloc: python: 22,776; makefile: 130; sh: 3
file content (33 lines) | stat: -rw-r--r-- 996 bytes parent folder | download | duplicates (2)
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
"""
Integration tests for stem.descriptor.microdescriptor.
"""

import os
import unittest

import stem.descriptor
import test.runner

from test.runner import only_run_once
from test.util import register_new_capability


class TestMicrodescriptor(unittest.TestCase):
  @only_run_once
  def test_cached_microdescriptors(self):
    """
    Parses the cached microdescriptor file in our data directory, checking that
    it doesn't raise any validation issues and looking for unrecognized
    descriptor additions.
    """

    descriptor_path = test.runner.get_runner().get_test_dir('cached-microdescs')

    if not os.path.exists(descriptor_path):
      test.runner.skip(self, '(no cached microdescriptors)')
      return

    with open(descriptor_path, 'rb') as descriptor_file:
      for desc in stem.descriptor.parse_file(descriptor_file, 'microdescriptor 1.0', validate = True):
        for line in desc.get_unrecognized_lines():
          register_new_capability('Microdescriptor Line', line)