Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 8ed332a

Browse files
committed
update test imports
1 parent 6258aa9 commit 8ed332a

18 files changed

+85
-113
lines changed

ethereum/tests/test_blockhashes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import pytest
2-
from pyethereum import tester
1+
from ethereum import tester
32

43

54
def test_blockhashes_10():
@@ -8,7 +7,7 @@ def test_blockhashes_10():
87
o = s.block.get_ancestor_list(256)
98
assert o[0] == s.block == s.blocks[10]
109
for i in range(1, 10):
11-
assert o[i] == s.blocks[10-i]
10+
assert o[i] == s.blocks[10 - i]
1211
for i in range(11, 257):
1312
assert o[i] is None
1413
assert len(o) == 257
@@ -20,5 +19,5 @@ def test_blockhashes_300():
2019
o = s.block.get_ancestor_list(256)
2120
assert o[0] == s.block == s.blocks[300]
2221
for i in range(1, 257):
23-
assert o[i] == s.blocks[300-i]
22+
assert o[i] == s.blocks[300 - i]
2423
assert len(o) == 257

ethereum/tests/test_blocks.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
from pyethereum import blocks, utils, db
2-
from pyethereum.exceptions import VerificationFailed, InvalidTransaction
1+
from ethereum import blocks, utils, db
2+
from ethereum.exceptions import VerificationFailed, InvalidTransaction
33
import rlp
44
from rlp.utils import decode_hex, encode_hex, str_to_bytes
55
from rlp import DecodingError, DeserializationError
6-
import pytest
76
import os
87
import sys
9-
import pyethereum.testutils as testutils
8+
import ethereum.testutils as testutils
109

11-
from pyethereum.slogging import get_logger, configure_logging
10+
from ethereum.slogging import get_logger
1211
logger = get_logger()
1312

1413

ethereum/tests/test_bloom.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import pytest
22
import json
3-
import pyethereum.processblock as pb
4-
import pyethereum.utils as utils
5-
import pyethereum.bloom as bloom
3+
import ethereum.processblock as pb
4+
import ethereum.utils as utils
5+
import ethereum.bloom as bloom
66
import os
7-
import sys
87
from rlp.utils import decode_hex, encode_hex, str_to_bytes
98

9+
1010
def check_testdata(data_keys, expected_keys):
1111
assert set(data_keys) == set(expected_keys), \
1212
"test data changed, please adjust tests"
@@ -45,11 +45,11 @@ def gen_func(testdata):
4545
globals()[func_name] = gen_func(testdata['logs'])
4646

4747

48-
4948
def decode_int_from_hex(x):
5049
r = utils.decode_int(decode_hex(x).lstrip(b"\x00"))
5150
return r
5251

52+
5353
def encode_hex_from_int(x):
5454
return encode_hex(utils.zpad(utils.int_to_big_endian(x), 256))
5555

@@ -74,4 +74,3 @@ def do_test_bloom(test_logs):
7474
log_bloom = bloom.b64(bloom.bloom_from_list(log.bloomables()))
7575
assert encode_hex(log_bloom) == encode_hex_from_int(b)
7676
assert str_to_bytes(data['bloom']) == encode_hex(log_bloom)
77-

ethereum/tests/test_chain.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import os
21
import pytest
3-
import json
4-
import pyethereum.processblock as processblock
5-
import pyethereum.blocks as blocks
6-
import pyethereum.transactions as transactions
2+
import ethereum.processblock as processblock
3+
import ethereum.blocks as blocks
4+
import ethereum.transactions as transactions
75
import rlp
86
from rlp.utils import decode_hex, encode_hex
9-
import pyethereum.trie as trie
10-
import pyethereum.miner as miner
11-
import pyethereum.utils as utils
12-
import pyethereum.ethash as ethash
13-
import pyethereum.ethash_utils as ethash_utils
14-
from pyethereum.db import DB, EphemDB
15-
from tests.utils import new_db, new_config, get_chainmanager, new_chainmanager
16-
17-
from pyethereum.slogging import get_logger, configure_logging
7+
import ethereum.miner as miner
8+
import ethereum.utils as utils
9+
import ethereum.ethash_utils as ethash_utils
10+
from ethereum.db import EphemDB
11+
from tests.utils import new_db, get_chainmanager, new_chainmanager
12+
13+
from ethereum.slogging import get_logger, configure_logging
1814
logger = get_logger()
1915
configure_logging('eth.vm:trace,eth.vm.memory:info')
2016

ethereum/tests/test_compress.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from pyethereum import compress
2-
import pytest
1+
from ethereum import compress
32

43

54
def test_compress():

ethereum/tests/test_contracts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import bitcoin
22
import os
33
import pytest
4-
from pyethereum import tester, utils, abi
4+
from ethereum import tester, utils, abi
55
import serpent
66
from rlp.utils import decode_hex, encode_hex
7-
from pyethereum.utils import safe_ord
7+
from ethereum.utils import safe_ord
88

99
# customize VM log output to your needs
1010
# hint: use 'py.test' with the '-s' option to dump logs to the console

ethereum/tests/test_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import random
33
import tempfile
44
import pytest
5-
from pyethereum.db import _EphemDB, _CodernityDB, _LevelDB
6-
from pyethereum.utils import db_path
5+
from ethereum.db import _EphemDB, _CodernityDB, _LevelDB
6+
from ethereum.utils import db_path
77
from rlp.utils import ascii_chr
88

99
random.seed(0)

ethereum/tests/test_genesis.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import os
21
import pytest
32
import json
4-
import pyethereum.blocks as blocks
5-
import rlp
3+
import ethereum.blocks as blocks
64
from rlp.utils import encode_hex
7-
import pyethereum.utils as utils
85
from tests.utils import new_db
9-
from pyethereum.slogging import get_logger, configure_logging
6+
from ethereum.slogging import get_logger, configure_logging
107
logger = get_logger()
118
configure_logging(':trace')
129

ethereum/tests/test_logging.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import os
2-
import pytest
31
import json
42
import logging
53
import logging.handlers
6-
import pyethereum.slogging as slogging
4+
import ethereum.slogging as slogging
75

86

97
class TestHandler(logging.handlers.BufferingHandler):
@@ -33,6 +31,7 @@ def get_test_handler():
3331
logging.getLogger().handlers = [th]
3432
return th
3533

34+
3635
def setup_logging(config_string='', log_json=False):
3736
# setsup default logging
3837
slogging.configure(config_string=config_string, log_json=log_json)
@@ -70,13 +69,15 @@ def test_baseconfig():
7069
config_string = ':inFO,a:trace,a.b:debug'
7170
th = setup_logging(config_string=config_string)
7271

72+
7373
def test_lvl_trace():
7474
config_string = ':trace'
7575
th = setup_logging(config_string=config_string)
7676
log = slogging.get_logger()
7777
assert th.does_log(log.debug)
7878
assert th.does_log(log.trace)
7979

80+
8081
def test_incremental():
8182
config_string = ':trace'
8283
th = setup_logging(config_string=config_string)
@@ -90,6 +91,7 @@ def test_incremental():
9091
l = th.logged
9192
assert 'first' in l and 'two' in l
9293

94+
9395
def test_jsonconfig():
9496
th = setup_logging(log_json=True)
9597
log = slogging.get_logger('prefix')
@@ -107,6 +109,7 @@ def test_kvprinter():
107109
l = th.logged
108110
assert 'baz' in l
109111

112+
110113
def test_namespaces():
111114
config_string = ':inFO,a:trace,a.b:debug'
112115
th = setup_logging(config_string=config_string)
@@ -120,25 +123,29 @@ def test_namespaces():
120123
assert th.does_log(log_a_b.debug)
121124
assert not th.does_log(log_a_b.trace)
122125

126+
123127
def test_tracebacks():
124128
th = setup_logging()
125129
log = slogging.get_logger()
126-
def div(a,b):
130+
131+
def div(a, b):
127132
try:
128-
r = a/b
133+
r = a / b
129134
log.error('heres the stack', stack_info=True)
130135
except Exception as e:
131136
log.error('an Exception trace should preceed this msg', exc_info=True)
132-
div(1,0)
137+
div(1, 0)
133138
assert 'an Exception' in th.logged
134-
div(1,1)
139+
div(1, 1)
135140
assert 'the stack' in th.logged
136141

142+
137143
def test_listeners():
138144
th = setup_logging()
139145
log = slogging.get_logger()
140146

141147
called = []
148+
142149
def log_cb(event_dict):
143150
called.append(event_dict)
144151

@@ -159,13 +166,15 @@ def log_cb(event_dict):
159166
assert 'nolistener' in th.logged
160167
assert not called
161168

169+
162170
def test_logger_names():
163171
th = setup_logging()
164-
names = set(['a','b','c'])
172+
names = set(['a', 'b', 'c'])
165173
for n in names:
166174
slogging.get_logger(n)
167175
assert names.issubset(set(slogging.get_logger_names()))
168176

177+
169178
def test_is_active():
170179
th = setup_logging()
171180
log = slogging.get_logger()
@@ -175,7 +184,7 @@ def test_is_active():
175184
assert log.is_active('warn')
176185

177186
# activate w/ listner
178-
slogging.log_listeners.listeners.append(lambda x:x)
187+
slogging.log_listeners.listeners.append(lambda x: x)
179188
assert log.is_active('trace')
180189
slogging.log_listeners.listeners.pop()
181190
assert not log.is_active('trace')
@@ -193,6 +202,7 @@ class LogMemory
193202
called_print = []
194203

195204
class Expensive(object):
205+
196206
def __structlog__(self):
197207
called_json.append(1)
198208
return 'expensive data preparation'
@@ -245,7 +255,6 @@ def test_get_configuration():
245255
assert set(config['config_string'].split(',')) == set(config_string.split(','))
246256

247257

248-
249258
def test_recorder():
250259
th = setup_logging()
251260
log = slogging.get_logger()
@@ -270,6 +279,7 @@ def test_recorder():
270279

271280
# examples
272281

282+
273283
def test_howto_use_in_tests():
274284
# select what you want to see.
275285
# e.g. TRACE from vm except for pre_state :DEBUG otherwise
@@ -302,5 +312,3 @@ def run_vm(raise_error=False):
302312
log = slogging.get_logger('eth.vm')
303313
for x in recorder.pop_records():
304314
log.info(x.pop('event'), **x)
305-
306-

ethereum/tests/test_remoteblocks.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
from pyethereum import blocks
2-
from pyethereum import processblock
3-
import rlp
4-
from rlp.utils import decode_hex, encode_hex
5-
from pyethereum import transactions
6-
from pyethereum.config import get_default_config
7-
from pyethereum.db import DB
8-
import pyethereum.utils as utils
9-
import logging
10-
import pytest
11-
import tempfile
12-
from tests.utils import new_chainmanager
13-
from pyethereum.slogging import get_logger, configure_logging
14-
from pyethereum import testutils
1+
from ethereum.db import DB
2+
from ethereum.slogging import get_logger, configure_logging
3+
from ethereum import testutils
154
import sys
165
logger = get_logger()
176
# customize VM log output to your needs

0 commit comments

Comments
 (0)