Skip to content

Commit

Permalink
Move complexity tests to their own module.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 25, 2023
1 parent 4515828 commit ed7a657
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
9 changes: 9 additions & 0 deletions tests/_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import importlib
import unittest


def import_or_skip(name):
try:
return importlib.import_module(name)
except ImportError: # pragma: no cover
raise unittest.SkipTest(f'Unable to import {name}')
24 changes: 24 additions & 0 deletions tests/test_complexity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
import string

import zipp
from jaraco.functools import compose
from more_itertools import consume

from ._support import import_or_skip


big_o = import_or_skip('big_o')


class TestComplexity(unittest.TestCase):
def test_implied_dirs_performance(self):
best, others = big_o.big_o(
compose(consume, zipp.CompleteDirs._implied_dirs),
lambda size: [
'/'.join(string.ascii_lowercase + str(n)) for n in range(size)
],
max_n=1000,
min_n=1,
)
assert best <= big_o.complexities.Linear
14 changes: 0 additions & 14 deletions tests/test_zipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
import tempfile
import shutil
import pickle
import string
import sys
import unittest
import zipfile

import big_o
import jaraco.itertools
from jaraco.functools import compose
from more_itertools import consume

import zipp

Expand Down Expand Up @@ -334,17 +331,6 @@ def test_joinpath_constant_time(self):
# Check the file iterated all items
assert entries.count == self.HUGE_ZIPFILE_NUM_ENTRIES

def test_implied_dirs_performance(self):
best, others = big_o.big_o(
compose(consume, zipp.CompleteDirs._implied_dirs),
lambda size: [
'/'.join(string.ascii_lowercase + str(n)) for n in range(size)
],
max_n=1000,
min_n=1,
)
assert best <= big_o.complexities.Linear

@pass_alpharep
def test_read_does_not_close(self, alpharep):
alpharep = self.zipfile_ondisk(alpharep)
Expand Down

0 comments on commit ed7a657

Please sign in to comment.