Skip to content

Commit

Permalink
better test infrastructure for test for large file
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwight Guth committed Aug 23, 2019
1 parent 11fcb61 commit 256f96e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
16 changes: 15 additions & 1 deletion tests/lib/test_yaml_ext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import _yaml, yaml
import types, pprint
import types, pprint, tempfile, sys

yaml.PyBaseLoader = yaml.BaseLoader
yaml.PySafeLoader = yaml.SafeLoader
Expand Down Expand Up @@ -233,6 +233,20 @@ def test_c_emitter(data_filename, canonical_filename, verbose=False):
test_c_emitter.unittest = ['.data', '.canonical']
test_c_emitter.skip = ['.skip-ext']

def test_large_file(verbose=False):
SIZE_LINE = 24
SIZE_ITERATION = 0
SIZE_FILE = 31
if sys.maxsize <= 2**32:
return
with tempfile.TemporaryFile() as temp_file:
for i in range(2**(SIZE_FILE-SIZE_ITERATION-SIZE_LINE) + 1):
temp_file.write(('-' + (' ' * (2**SIZE_LINE-4))+ '{}\n')*(2**SIZE_ITERATION))
temp_file.seek(0)
yaml.load(temp_file, Loader=yaml.CLoader)

test_large_file.unittest = None

def wrap_ext_function(function):
def wrapper(*args, **kwds):
_set_up()
Expand Down
16 changes: 15 additions & 1 deletion tests/lib3/test_yaml_ext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import _yaml, yaml
import types, pprint
import types, pprint, tempfile, sys

yaml.PyBaseLoader = yaml.BaseLoader
yaml.PySafeLoader = yaml.SafeLoader
Expand Down Expand Up @@ -233,6 +233,20 @@ def test_c_emitter(data_filename, canonical_filename, verbose=False):
test_c_emitter.unittest = ['.data', '.canonical']
test_c_emitter.skip = ['.skip-ext']

def test_large_file(verbose=False):
SIZE_LINE = 24
SIZE_ITERATION = 0
SIZE_FILE = 31
if sys.maxsize <= 2**32:
return
with tempfile.TemporaryFile() as temp_file:
for i in range(2**(SIZE_FILE-SIZE_ITERATION-SIZE_LINE) + 1):
temp_file.write(bytes(('-' + (' ' * (2**SIZE_LINE-4))+ '{}\n')*(2**SIZE_ITERATION), 'utf-8'))
temp_file.seek(0)
yaml.load(temp_file, Loader=yaml.CLoader)

test_large_file.unittest = None

def wrap_ext_function(function):
def wrapper(*args, **kwds):
_set_up()
Expand Down

0 comments on commit 256f96e

Please sign in to comment.