add mod_floor() and mod_ceil(), fix b64*() taking a wrong turn

This commit is contained in:
Yusur 2025-07-19 23:09:16 +02:00
parent 8a16fe159f
commit 3188b59c15
7 changed files with 86 additions and 18 deletions

View file

@ -2,7 +2,7 @@
import binascii
import unittest
from suou.codecs import b64encode, b64decode
from suou.codecs import b64encode, b64decode, want_urlsafe
B1 = b'N\xf0\xb4\xc3\x85\n\xf9\xb6\x9a\x0f\x82\xa6\x99G\x07#'
B2 = b'\xbcXiF,@|{\xbe\xe3\x0cz\xa8\xcbQ\x82'
@ -47,4 +47,8 @@ class TestCodecs(unittest.TestCase):
self.assertRaises(binascii.Error, b64decode, 'C')
def test_want_urlsafe(self):
self.assertEqual('__init__', want_urlsafe('//init_/'))
self.assertEqual('Disney-', want_urlsafe('Disney+'))
self.assertEqual('spaziocosenza', want_urlsafe('spazio cosenza'))
self.assertEqual('=======', want_urlsafe('======='))

View file

@ -4,6 +4,7 @@
import unittest
from suou.strtools import PrefixIdentifier
from pydantic import ValidationError
class TestStrtools(unittest.TestCase):
def setUp(self) -> None:
@ -19,12 +20,12 @@ class TestStrtools(unittest.TestCase):
self.assertEqual(pi['\x1b\x00'], '\x1b\0')
self.assertEqual(pi.same_thing, pi['same_thing'])
with self.assertRaises(TypeError):
with self.assertRaises(ValidationError):
pi[0]
self.assertEqual(PrefixIdentifier(None), PrefixIdentifier(''))
self.assertEqual(f'{PrefixIdentifier(None)}', f'{PrefixIdentifier("")}')
def test_PrefixIdentifier_invalid(self):
def test_PrefixIdentifier_get_nostr(self):
with self.assertRaises(TypeError):
pi = PrefixIdentifier(1)
pi.hello
@ -35,4 +36,5 @@ class TestStrtools(unittest.TestCase):
with self.assertRaises(TypeError):
PrefixIdentifier(b'alpha_')