Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use import *s to preserve old single import api

  • Loading branch information...
commit 5c90844f635c513a8f726186a5390530baa977d9 1 parent 15354f6
@schmichael authored
View
3  mmstats/__init__.py
@@ -0,0 +1,3 @@
+from .defaults import *
+from .fields import *
+from .models import *
View
17 tests/test_mmap.py
@@ -4,47 +4,48 @@
import os
import mmstats
+from mmstats import _mmap
class TestMmap(base.MmstatsTestCase):
def test_pagesize(self):
"""PAGESIZE > 0"""
- self.assertTrue(mmstats.PAGESIZE > 0, mmstats.PAGESIZE)
+ self.assertTrue(_mmap.PAGESIZE > 0, _mmap.PAGESIZE)
def test_init_alt_name(self):
expected_fn = os.path.join(self.path, 'mmstats-test_init_alt_name')
self.assertFalse(os.path.exists(expected_fn))
- _, fn, sz, m = mmstats._init_mmap(
+ _, fn, sz, m = _mmap.init_mmap(
path=self.path, filename='mmstats-test_init_alt_name')
self.assertEqual(fn, expected_fn)
self.assertTrue(os.path.exists(fn))
def test_size_adjusting1(self):
"""mmapped files must be at least PAGESIZE in size"""
- _, _, sz, m = mmstats._init_mmap(path=self.path,
+ _, _, sz, m = _mmap.init_mmap(path=self.path,
filename='mmstats-test_size_adjusting-1', size=1)
- self.assertEqual(sz, mmstats.PAGESIZE)
+ self.assertEqual(sz, _mmap.PAGESIZE)
for i in range(sz):
self.assertEqual(ctypes.c_char.from_address(m+i).value, '\x00')
def test_size_adjusting2(self):
"""mmapped files must be multiples of PAGESIZE"""
- _, _, sz, m = mmstats._init_mmap(
+ _, _, sz, m = _mmap.init_mmap(
path=self.path,
filename='mmstats-test_size_adjusting-2',
- size=(mmstats.PAGESIZE + 1)
+ size=(_mmap.PAGESIZE + 1)
)
- self.assertEqual(sz, mmstats.PAGESIZE * 2)
+ self.assertEqual(sz, _mmap.PAGESIZE * 2)
for i in range(sz):
self.assertEqual(ctypes.c_char.from_address(m+i).value, '\x00')
def test_truncate(self):
"""mmapped files must be initialized with null bytes"""
- _, fn, sz, m = mmstats._init_mmap(
+ _, fn, sz, m = _mmap.init_mmap(
path=self.path,
filename='mmstats-test_truncate',
)
View
15 tests/test_mmstats.py
@@ -1,6 +1,7 @@
from . import base
import mmstats
+from mmstats import _mmap
class TestMmStats(base.MmstatsTestCase):
@@ -50,20 +51,20 @@ class StatsA(mmstats.MmStats):
def test_mmap_resize1(self):
class BigStats(mmstats.MmStats):
- f1 = mmstats.BoolField(label='f1'*(mmstats.PAGESIZE / 2))
- f2 = mmstats.BoolField(label='f2'*(mmstats.PAGESIZE / 2))
+ f1 = mmstats.BoolField(label='f1'*(_mmap.PAGESIZE / 2))
+ f2 = mmstats.BoolField(label='f2'*(_mmap.PAGESIZE / 2))
bs = BigStats(filename='mmstats-test-resize2')
- self.assertEqual(bs.size, mmstats.PAGESIZE * 3)
+ self.assertEqual(bs.size, _mmap.PAGESIZE * 3)
def test_mmap_resize2(self):
class BigStats(mmstats.MmStats):
- f1 = mmstats.UIntField(label='f'+('o'*mmstats.PAGESIZE))
- f2 = mmstats.UIntField(label='f'+('0'*mmstats.PAGESIZE))
- f3 = mmstats.UIntField(label='f'+('1'*mmstats.PAGESIZE))
+ f1 = mmstats.UIntField(label='f'+('o'*_mmap.PAGESIZE))
+ f2 = mmstats.UIntField(label='f'+('0'*_mmap.PAGESIZE))
+ f3 = mmstats.UIntField(label='f'+('1'*_mmap.PAGESIZE))
bs = BigStats(filename='mmstats-test-resize2')
- self.assertEqual(bs.size, mmstats.PAGESIZE * 4)
+ self.assertEqual(bs.size, _mmap.PAGESIZE * 4)
self.assertEqual(bs.f1, 0)
self.assertEqual(bs.f2, 0)
self.assertEqual(bs.f3, 0)
Please sign in to comment.
Something went wrong with that request. Please try again.