~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/tests/__init__.py

  • Committer: Tristan Seligmann
  • Date: 2009-04-27 23:53:32 UTC
  • mfrom: (3.1.5 client)
  • Revision ID: mithrandi@mithrandi.net-20090427235332-l8azkl1kvn5pjtay
mergeĀ lp:~lifeless/txaws/client

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
 
 
3
from twisted.trial.unittest import TestCase
 
4
 
 
5
class TXAWSTestCase(TestCase):
 
6
    """Support for isolation of txaws tests."""
 
7
 
 
8
    def setUp(self):
 
9
        TestCase.setUp(self)
 
10
        self.stash_environ()
 
11
 
 
12
    def stash_environ(self):
 
13
        self.orig_environ = dict(os.environ)
 
14
        self.addCleanup(self.restore_environ)
 
15
        if 'AWS_ACCESS_KEY_ID' in os.environ:
 
16
            del os.environ['AWS_ACCESS_KEY_ID']
 
17
        if 'AWS_SECRET_ACCESS_KEY' in os.environ:
 
18
            del os.environ['AWS_SECRET_ACCESS_KEY']
 
19
 
 
20
    def restore_environ(self):
 
21
        for key in set(os.environ) - set(self.orig_environ):
 
22
            del os.environ[key]
 
23
        os.environ.update(self.orig_environ)
 
24