From be21606075cbc15018d1f36c2581ab138e4a44cc Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Thu, 23 Dec 2021 10:09:18 +0000 Subject: [PATCH] my.reddit: better handling for legacy reddit config prior to this change it would error with @dataclass > class pushshift_config(uconfig.pushshift): E AttributeError: type object 'test_config' has no attribute 'pushshift' --- my/reddit/pushshift.py | 4 +++- tests/reddit.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/my/reddit/pushshift.py b/my/reddit/pushshift.py index e67db84..1c7ec8d 100644 --- a/my/reddit/pushshift.py +++ b/my/reddit/pushshift.py @@ -12,6 +12,9 @@ from my.core.common import Paths, Stats from dataclasses import dataclass from my.core.cfg import make_config +# note: keeping pushshift import before config import, so it's handled gracefully by import_source +from pushshift_comment_export.dal import read_file, PComment + from my.config import reddit as uconfig @dataclass @@ -29,7 +32,6 @@ from my.core import get_files from typing import Sequence, Iterator from pathlib import Path -from pushshift_comment_export.dal import read_file, PComment def inputs() -> Sequence[Path]: diff --git a/tests/reddit.py b/tests/reddit.py index a7b4265..d18b18d 100644 --- a/tests/reddit.py +++ b/tests/reddit.py @@ -11,6 +11,11 @@ def test_basic() -> None: assert len(list(saved())) > 0 +def test_comments() -> None: + from my.reddit.all import comments + assert len(list(comments())) > 0 + + def test_unfav() -> None: from my.reddit import events, saved ev = events()