Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run examples with warnings #610

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7f618f8
Run examples with warnings
Dreamsorcerer Dec 31, 2022
411e0ac
Update serializer_class.py
Dreamsorcerer Dec 31, 2022
71bf6d4
Update serializer_class.py
Dreamsorcerer Dec 31, 2022
d0e88d5
Update serializer_class.py
Dreamsorcerer Dec 31, 2022
791a8d1
Update serializer_class.py
Dreamsorcerer Dec 31, 2022
b250f53
Update run_all.sh
Dreamsorcerer Dec 31, 2022
71b065c
Update run_all.sh
Dreamsorcerer Dec 31, 2022
9ed339e
Update run_all.sh
Dreamsorcerer Dec 31, 2022
4cfada3
Update run_all.sh
Dreamsorcerer Dec 31, 2022
6f0b5ba
Update run_all.sh
Dreamsorcerer Dec 31, 2022
effe17b
Update run_all.sh
Dreamsorcerer Dec 31, 2022
63ca524
Update run_all.sh
Dreamsorcerer Dec 31, 2022
f46f64b
Update run_all.sh
Dreamsorcerer Dec 31, 2022
0ba2a45
Update cached_alias_config.py
Dreamsorcerer Dec 31, 2022
113be21
Update cached_decorator.py
Dreamsorcerer Dec 31, 2022
86a4b0f
Update marshmallow_serializer_class.py
Dreamsorcerer Dec 31, 2022
819ffde
Update multicached_decorator.py
Dreamsorcerer Dec 31, 2022
5203cc8
Update optimistic_lock.py
Dreamsorcerer Dec 31, 2022
391d846
Update plugins.py
Dreamsorcerer Dec 31, 2022
bdfc8cc
Update python_object.py
Dreamsorcerer Dec 31, 2022
b332806
Update redlock.py
Dreamsorcerer Dec 31, 2022
1d09124
Update serializer_class.py
Dreamsorcerer Dec 31, 2022
a6bdd4e
Update serializer_function.py
Dreamsorcerer Dec 31, 2022
313bc4a
Update simple_redis.py
Dreamsorcerer Dec 31, 2022
d1cb537
Update run_all.sh
Dreamsorcerer Dec 31, 2022
9ff5b09
Update run_all.sh
Dreamsorcerer Jan 2, 2023
d7a83bb
Update run_all.sh
Dreamsorcerer Jan 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/cached_alias_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def alt_cache():
await cache.close()


async def test_alias():
async def main() -> None:
await default_cache()
await alt_cache()

Expand All @@ -63,4 +63,4 @@ async def test_alias():


if __name__ == "__main__":
asyncio.run(test_alias())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/cached_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async def cached_call():
return Result("content", 200)


async def test_cached():
async def main() -> None:
async with Cache(Cache.REDIS, endpoint="127.0.0.1", port=6379, namespace="main") as cache:
await cached_call()
exists = await cache.exists("key")
Expand All @@ -24,4 +24,4 @@ async def test_cached():


if __name__ == "__main__":
asyncio.run(test_cached())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/marshmallow_serializer_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ async def serializer():
assert result.list_type == model.list_type


async def test_serializer():
async def main() -> None:
await serializer()
await cache.delete("key")


if __name__ == "__main__":
asyncio.run(test_serializer())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/multicached_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def multi_cached_keys(keys=None):
cache = Cache(Cache.REDIS, endpoint="127.0.0.1", port=6379, namespace="main")


async def test_multi_cached():
async def main() -> None:
await multi_cached_ids(ids=("a", "b"))
await multi_cached_ids(ids=("a", "c"))
await multi_cached_keys(keys=("d",))
Expand All @@ -41,4 +41,4 @@ async def test_multi_cached():


if __name__ == "__main__":
asyncio.run(test_multi_cached())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/optimistic_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ async def concurrent():
await asyncio.gather(my_view(), my_view(), my_view())


async def test_redis():
async def main() -> None:
await concurrent()
await cache.delete("key")
await cache.close()


if __name__ == '__main__':
asyncio.run(test_redis())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def run():
print(cache.profiling)


async def test_run():
async def main() -> None:
await run()
await cache.delete("a")
await cache.delete("b")
Expand All @@ -55,4 +55,4 @@ async def test_run():


if __name__ == "__main__":
asyncio.run(test_run())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/python_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ async def complex_object():
assert my_object.y == 2


async def test_python_object():
async def main() -> None:
await complex_object()
await cache.delete("key")
await cache.close()


if __name__ == "__main__":
asyncio.run(test_python_object())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/redlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ async def concurrent():
await asyncio.gather(my_view(), my_view(), my_view())


async def test_redis():
async def main() -> None:
await concurrent()
await cache.delete("key")
await cache.close()


if __name__ == '__main__':
asyncio.run(test_redis())
asyncio.run(main())
8 changes: 6 additions & 2 deletions examples/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ pushd "$(dirname "$0")"

for f in `find . -name '*.py' -not -path "./frameworks/*"`; do
echo "########## Running $f #########"
python $f || exit 1
echo;echo;echo
# ResourceWarning in __del__ fails to exit 1, so we grep for warnings.
# Did try using sys.unraisablehook, but it wasn't working.
python -bb -We -X dev $f 2>&1 | tee /dev/stderr | ( ! fgrep -i 'warning' > /dev/null ) || exit 1
if [ ${PIPESTATUS[0]} -ne 0 ]; then
exit 1
fi
done

popd
8 changes: 4 additions & 4 deletions examples/serializer_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class CompressionSerializer(BaseSerializer):
def dumps(self, value):
print("I've received:\n{}".format(value))
compressed = zlib.compress(value.encode())
print("But I'm storing:\n{}".format(compressed))
print("But I'm storing:\n{!r}".format(compressed))
return compressed

def loads(self, value):
print("I've retrieved:\n{}".format(value))
print("I've retrieved:\n{!r}".format(value))
decompressed = zlib.decompress(value).decode()
print("But I'm returning:\n{}".format(decompressed))
return decompressed
Expand All @@ -43,11 +43,11 @@ async def serializer():
assert len(compressed_value) < len(real_value.encode())


async def test_serializer():
async def main() -> None:
await serializer()
await cache.delete("key")
await cache.close()


if __name__ == "__main__":
asyncio.run(test_serializer())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/serializer_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ async def serializer_function():
assert json.loads(await cache.raw("get", "main:key")) == {"y": 2.0, "x": 1.0}


async def test_serializer_function():
async def main() -> None:
await serializer_function()
await cache.delete("key")
await cache.close()


if __name__ == "__main__":
asyncio.run(test_serializer_function())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/simple_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ async def redis():
assert await cache.raw("ttl", "main:expire_me") > 0


async def test_redis():
async def main() -> None:
await redis()
await cache.delete("key")
await cache.delete("expire_me")
await cache.close()


if __name__ == "__main__":
asyncio.run(test_redis())
asyncio.run(main())