Commit f8b45679 authored by sand's avatar sand

update tests

parent 22e89de0
...@@ -3,7 +3,6 @@ import shutil ...@@ -3,7 +3,6 @@ import shutil
import tempfile import tempfile
import unittest import unittest
import smtplib import smtplib
import gnupg
from email.mime.image import MIMEImage from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
...@@ -11,8 +10,13 @@ from email.mime.text import MIMEText ...@@ -11,8 +10,13 @@ from email.mime.text import MIMEText
import pgp_mime_lib import pgp_mime_lib
import logging
logging.getLogger('gnupg').setLevel(logging.DEBUG)
logging.basicConfig()
fixtures_dir = os.path.join(os.path.dirname(__file__), 'fixtures') fixtures_dir = os.path.join(os.path.dirname(__file__), 'fixtures')
secret_key_dir = os.path.join(fixtures_dir, "gnupghome/private-keys-v1.d")
class TestBase(unittest.TestCase): class TestBase(unittest.TestCase):
...@@ -22,16 +26,15 @@ class TestBase(unittest.TestCase): ...@@ -22,16 +26,15 @@ class TestBase(unittest.TestCase):
# Load our test secret key. # Load our test secret key.
self.public_keyring = os.path.join( self.public_keyring = os.path.join(
fixtures_dir, 'secret/pubring.gpg') fixtures_dir, 'gnupghome/pubring.gpg')
self.secret_keyring = os.path.join( self.secret_key_dir = secret_key_dir
fixtures_dir, 'secret/secring.gpg')
self.secret_key = '0x56A1E35992BCB5CF' self.secret_key = '0x56A1E35992BCB5CF'
def tearDown(self): def tearDown(self):
shutil.rmtree(self.dir) shutil.rmtree(self.dir)
def _gpg(self): def _gpg(self):
return pgp_mime_lib.GPG(self.secret_key, self.public_keyring, self.secret_keyring) return pgp_mime_lib.GPG(self.secret_key, self.public_keyring, self.secret_key_dir)
class TestSign(TestBase): class TestSign(TestBase):
...@@ -188,7 +191,7 @@ class TestMIME(TestBase): ...@@ -188,7 +191,7 @@ class TestMIME(TestBase):
m = MIMEText(u'test message') m = MIMEText(u'test message')
m.replace_header('Content-Transfer-Encoding', '8bit') m.replace_header('Content-Transfer-Encoding', '8bit')
self._encrypt(m) self._encrypt(m)
def test_multipart_message_with_image(self): def test_multipart_message_with_image(self):
msg = MIMEMultipart() msg = MIMEMultipart()
msg.preamble = 'This is a message with an image attachment' msg.preamble = 'This is a message with an image attachment'
......
[tox] [tox]
envlist = py27 envlist = py27, py3, flake8
[testenv] [testenv]
deps= deps=
nose pytest
coverage pytest-cov
commands= setenv =
/usr/bin/env LANG=en_US.UTF-8 \ LANG=en_US.UTF-8
nosetests -v \ GNUPG=/usr/bin/gpg
--with-coverage --cover-package=pgp_mime_lib \ commands =
--cover-erase --cover-html --cover-html-dir=htmlcov \ # run pytest with -x --pdb to drop into pdb at the first failure
[] pytest --cov=pgp_mime_lib --cov-report html:htmlcov --cov-report term {posargs}
[testenv:flake8]
basepython = python3
deps =
flake8
flake8-builtins
flake8-bugbear
skip_install = true
commands = flake8 pgp_mime_lib/ setup.py
[flake8]
exclude = .tox/*, .git/*, build/*, pgp_mime_lib/_compat.py
max-line-length = 100
select =
E,F,W,C90,B,B902,C
[pytest]
norecursedirs = .tox
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment