Convenience functions for callable hooks
[mediagoblin.git] / mediagoblin / tests / test_storage.py
index eab4d0325fe845095b5b0cbec9151dd2b624fed1..294fec7dcde51f2aad0f00c6de1148f465f14ab1 100644 (file)
@@ -1,5 +1,5 @@
 # GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011 MediaGoblin contributors.  See AUTHORS.
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
@@ -18,7 +18,7 @@
 import os
 import tempfile
 
-from nose.tools import assert_raises
+import pytest
 from werkzeug.utils import secure_filename
 
 from mediagoblin import storage
@@ -41,10 +41,8 @@ def test_clean_listy_filepath():
     assert storage.clean_listy_filepath(
         ['../../../etc/', 'passwd']) == expected
 
-    assert_raises(
-        storage.InvalidFilepath,
-        storage.clean_listy_filepath,
-        ['../../', 'linooks.jpg'])
+    with pytest.raises(storage.InvalidFilepath):
+        storage.clean_listy_filepath(['../../', 'linooks.jpg'])
 
 
 class FakeStorageSystem():
@@ -80,7 +78,8 @@ def test_storage_system_from_config():
              'mediagoblin.tests.test_storage:FakeStorageSystem'})
     assert this_storage.foobie == 'eiboof'
     assert this_storage.blech == 'hcelb'
-    assert this_storage.__class__ is FakeStorageSystem
+    assert unicode(this_storage.__class__) == \
+        u'mediagoblin.tests.test_storage.FakeStorageSystem'
 
 
 ##########################
@@ -107,7 +106,7 @@ def test_basic_storage__resolve_filepath():
     assert result == os.path.join(
         tmpdir, 'etc/passwd')
 
-    assert_raises(
+    pytest.raises(
         storage.InvalidFilepath,
         this_storage._resolve_filepath,
         ['../../', 'etc', 'passwd'])
@@ -204,7 +203,7 @@ def test_basic_storage_delete_file():
 def test_basic_storage_url_for_file():
     # Not supplying a base_url should actually just bork.
     tmpdir, this_storage = get_tmp_filestorage()
-    assert_raises(
+    pytest.raises(
         storage.NoWebServing,
         this_storage.file_url,
         ['dir1', 'dir2', 'filename.txt'])