-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconftest.py
46 lines (35 loc) · 1.02 KB
/
conftest.py
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
from __future__ import unicode_literals
import pytest
import io
try:
import configparser
except ImportError:
import ConfigParser as configparser
from onionrouter import rerouter, config_handlers
config = """
[RESOLVER]
resolver_ip: 127.0.0.1
resolver_port: 53
tcp: True
[DOMAIN]
hostname: myself.net, myself2.net
[DNS]
srv_record: _onion-mx._tcp.
[REROUTE]
onion_transport: smtptor
[IGNORED]
domains: ignore.me, ignore2.me
"""
@pytest.fixture(scope="session", name="dummy_config")
def fixture_config():
return config
@pytest.fixture(scope="function", name="dummy_onionrouter")
def fixture_onionrouter(monkeypatch, dummy_config):
monkeypatch.setattr(
config_handlers, "get_conffile",
lambda *args, **kwargs: rerouter.OnionRouter.ref_config)
custom_config = configparser.ConfigParser()
custom_config._read(io.StringIO(dummy_config), None)
monkeypatch.setattr(config_handlers, "config_reader",
lambda *args: custom_config)
return rerouter.OnionRouter("nothing?")