Skip to content

Commit

Permalink
ensure the AntiSpam.tweet_store is cleared prior to test running, tur…
Browse files Browse the repository at this point in the history
…ned off spam filtering by default in formatting tests
  • Loading branch information
a-tal committed Apr 12, 2014
1 parent e2fc527 commit 4086ce6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test/test_anti_spam.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def set_test_timeout(request):

@pytest.fixture
def clear_store():
AntiSpam.clear()
AntiSpam.tweet_store = {}
AntiSpam.timeout = 600


Expand Down
17 changes: 5 additions & 12 deletions test/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,35 @@

from __future__ import unicode_literals

import os
import sys
import json
import pytest

if sys.version_info > (3,):
from io import StringIO
else:
from StringIO import StringIO

from pyweet.spam import AntiSpam
from pyweet.base import print_tweet, parse_date, parse_args


STDOUT = None



@pytest.fixture
def settings():
return parse_args()
_settings = parse_args()
_settings.update({"spam": True})
return _settings


@pytest.fixture(autouse=True)
def test_setup(request):
"""Register the finalizer."""

AntiSpam.tweet_store = {}
request.addfinalizer(test_teardown)


@pytest.fixture
def test_teardown():
"""Reset argv and clear the AntiSpam."""

while len(sys.argv) > 1:
sys.argv.pop(-1)
AntiSpam.tweet_store = {}


def test_basic_tweet_parsing(tweet, settings, capfd):
Expand Down Expand Up @@ -97,6 +89,7 @@ def test_parsing_with_time_and_date(tweet, settings, capfd):
def test_second_parse_is_spam(tweet, settings, capfd):
"""The second identical tweet should be caught and not printed."""

settings.update({"spam": False})
print_tweet(tweet, settings)
out, _ = capfd.readouterr()
assert (
Expand Down

0 comments on commit 4086ce6

Please sign in to comment.