This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch dw/8455-part2
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 768e1cd0fe7cbbeab70fdeb81c33387edc071c41
Author: Dillon Walls <[email protected]>
AuthorDate: Thu Sep 29 17:12:40 2022 +0000

    fixup! [#8455] remove @with_setup
---
 Allura/allura/tests/model/test_artifact.py | 493 ++++++++++++++---------------
 Allura/allura/tests/model/test_auth.py     |  67 ++--
 2 files changed, 265 insertions(+), 295 deletions(-)

diff --git a/Allura/allura/tests/model/test_artifact.py 
b/Allura/allura/tests/model/test_artifact.py
index 940ae0cac..35402dd0c 100644
--- a/Allura/allura/tests/model/test_artifact.py
+++ b/Allura/allura/tests/model/test_artifact.py
@@ -22,7 +22,6 @@ import re
 from datetime import datetime
 
 from tg import tmpl_context as c
-from alluratest.tools import with_setup
 from mock import patch
 import pytest
 from ming.orm.ormsession import ThreadLocalORMSession
@@ -55,273 +54,239 @@ class Checkmessage(M.Message):
 Mapper.compile_all()
 
 
-def setup_method():
-    setup_basic_test()
-    setup_unit_test()
-    setup_with_tools()
-
-
-def teardown_module():
-    ThreadLocalORMSession.close_all()
-
-
[email protected]_wiki
-def setup_with_tools():
-    h.set_context('test', 'wiki', neighborhood='Projects')
-    Checkmessage.query.remove({})
-    WM.Page.query.remove({})
-    WM.PageHistory.query.remove({})
-    M.Shortlink.query.remove({})
-    c.user = M.User.query.get(username='test-admin')
-    Checkmessage.project = c.project
-    Checkmessage.app_config = c.app.config
-
-
-@with_setup(setup_method)
-def test_artifact():
-    pg = WM.Page(title='TestPage1')
-    assert pg.project == c.project
-    assert pg.project_id == c.project._id
-    assert pg.app.config == c.app.config
-    assert pg.app_config == c.app.config
-    u = M.User.query.get(username='test-user')
-    pr = M.ProjectRole.by_user(u, upsert=True)
-    ThreadLocalORMSession.flush_all()
-    REGISTRY.register(allura.credentials, allura.lib.security.Credentials())
-    assert not security.has_access(pg, 'delete')(user=u)
-    pg.acl.append(M.ACE.allow(pr._id, 'delete'))
-    ThreadLocalORMSession.flush_all()
-    assert security.has_access(pg, 'delete')(user=u)
-    pg.acl.pop()
-    ThreadLocalORMSession.flush_all()
-    assert not security.has_access(pg, 'delete')(user=u)
-
-
-def test_artifact_index():
-    pg = WM.Page(title='TestPage1')
-    idx = pg.index()
-    assert 'title' in idx
-    assert 'url_s' in idx
-    assert 'project_id_s' in idx
-    assert 'mount_point_s' in idx
-    assert 'type_s' in idx
-    assert 'id' in idx
-    assert idx['id'] == pg.index_id()
-    assert 'text' in idx
-    assert 'TestPage' in pg.shorthand_id()
-    assert pg.link_text() == pg.shorthand_id()
-
-
-@with_setup(setup_method)
-def test_artifactlink():
-    pg = WM.Page(title='TestPage2')
-    q_shortlink = M.Shortlink.query.find(dict(
-        project_id=c.project._id,
-        app_config_id=c.app.config._id,
-        link=pg.shorthand_id()))
-    assert q_shortlink.count() == 0
-
-    ThreadLocalORMSession.flush_all()
-    M.MonQTask.run_ready()
-    ThreadLocalORMSession.flush_all()
-    assert q_shortlink.count() == 1
-
-    assert M.Shortlink.lookup('[TestPage2]')
-    assert M.Shortlink.lookup('[wiki:TestPage2]')
-    assert M.Shortlink.lookup('[test:wiki:TestPage2]')
-    assert not M.Shortlink.lookup('[test:wiki:TestPage2:foo]')
-    assert not M.Shortlink.lookup('[Wiki:TestPage2]')
-    assert not M.Shortlink.lookup('[TestPage2_no_such_page]')
-
-    pg.delete()
-    c.project.uninstall_app('wiki')
-    assert not M.Shortlink.lookup('[wiki:TestPage2]')
-    assert q_shortlink.count() == 0
-
-
-@with_setup(setup_method)
-def test_gen_messageid():
-    assert re.match(r'[0-9a-zA-Z]*[email protected]',
-                    h.gen_message_id())
-
-
-@with_setup(setup_method)
-def test_gen_messageid_with_id_set():
-    oid = ObjectId()
-    assert re.match(r'%[email protected]' %
-                    str(oid), h.gen_message_id(oid))
-
-
-@with_setup(setup_method)
-def test_artifact_messageid():
-    p = WM.Page(title='T')
-    assert re.match(r'%[email protected]' %
-                    str(p._id), p.message_id())
-
-
-@with_setup(setup_method)
-def test_versioning():
-    pg = WM.Page(title='TestPage3')
-    with patch('allura.model.artifact.request',
-               Request.blank('/', remote_addr='1.1.1.1')):
+class TestArtifact:
+
+    def setup_method(self):
+        setup_basic_test()
+        setup_unit_test()
+        self.setup_with_tools()
+
+    def teardown_class(cls):
+        ThreadLocalORMSession.close_all()
+
+    @td.with_wiki
+    def setup_with_tools(self):
+        h.set_context('test', 'wiki', neighborhood='Projects')
+        Checkmessage.query.remove({})
+        WM.Page.query.remove({})
+        WM.PageHistory.query.remove({})
+        M.Shortlink.query.remove({})
+        c.user = M.User.query.get(username='test-admin')
+        Checkmessage.project = c.project
+        Checkmessage.app_config = c.app.config
+
+    def test_artifact(self):
+        pg = WM.Page(title='TestPage1')
+        assert pg.project == c.project
+        assert pg.project_id == c.project._id
+        assert pg.app.config == c.app.config
+        assert pg.app_config == c.app.config
+        u = M.User.query.get(username='test-user')
+        pr = M.ProjectRole.by_user(u, upsert=True)
+        ThreadLocalORMSession.flush_all()
+        REGISTRY.register(allura.credentials, 
allura.lib.security.Credentials())
+        assert not security.has_access(pg, 'delete')(user=u)
+        pg.acl.append(M.ACE.allow(pr._id, 'delete'))
+        ThreadLocalORMSession.flush_all()
+        assert security.has_access(pg, 'delete')(user=u)
+        pg.acl.pop()
+        ThreadLocalORMSession.flush_all()
+        assert not security.has_access(pg, 'delete')(user=u)
+
+    def test_artifact_index(self):
+        pg = WM.Page(title='TestPage1')
+        idx = pg.index()
+        assert 'title' in idx
+        assert 'url_s' in idx
+        assert 'project_id_s' in idx
+        assert 'mount_point_s' in idx
+        assert 'type_s' in idx
+        assert 'id' in idx
+        assert idx['id'] == pg.index_id()
+        assert 'text' in idx
+        assert 'TestPage' in pg.shorthand_id()
+        assert pg.link_text() == pg.shorthand_id()
+
+    def test_artifactlink(self):
+        pg = WM.Page(title='TestPage2')
+        q_shortlink = M.Shortlink.query.find(dict(
+            project_id=c.project._id,
+            app_config_id=c.app.config._id,
+            link=pg.shorthand_id()))
+        assert q_shortlink.count() == 0
+
+        ThreadLocalORMSession.flush_all()
+        M.MonQTask.run_ready()
+        ThreadLocalORMSession.flush_all()
+        assert q_shortlink.count() == 1
+
+        assert M.Shortlink.lookup('[TestPage2]')
+        assert M.Shortlink.lookup('[wiki:TestPage2]')
+        assert M.Shortlink.lookup('[test:wiki:TestPage2]')
+        assert not M.Shortlink.lookup('[test:wiki:TestPage2:foo]')
+        assert not M.Shortlink.lookup('[Wiki:TestPage2]')
+        assert not M.Shortlink.lookup('[TestPage2_no_such_page]')
+
+        pg.delete()
+        c.project.uninstall_app('wiki')
+        assert not M.Shortlink.lookup('[wiki:TestPage2]')
+        assert q_shortlink.count() == 0
+
+    def test_gen_messageid(self):
+        assert re.match(r'[0-9a-zA-Z]*[email protected]',
+                        h.gen_message_id())
+
+    def test_gen_messageid_with_id_set(self):
+        oid = ObjectId()
+        assert re.match(r'%[email protected]' %
+                        str(oid), h.gen_message_id(oid))
+
+    def test_artifact_messageid(self):
+        p = WM.Page(title='T')
+        assert re.match(r'%[email protected]' %
+                        str(p._id), p.message_id())
+
+    def test_versioning(self):
+        pg = WM.Page(title='TestPage3')
+        with patch('allura.model.artifact.request', Request.blank('/', 
remote_addr='1.1.1.1')):
+            pg.commit()
+        ThreadLocalORMSession.flush_all()
+        pg.text = 'Here is some text'
         pg.commit()
-    ThreadLocalORMSession.flush_all()
-    pg.text = 'Here is some text'
-    pg.commit()
-    ThreadLocalORMSession.flush_all()
-    ss = pg.get_version(1)
-    assert ss.author.logged_ip == '1.1.1.1'
-    assert ss.index()['is_history_b']
-    assert ss.shorthand_id() == pg.shorthand_id() + '#1'
-    assert ss.title == pg.title
-    assert ss.text != pg.text
-    ss = pg.get_version(-1)
-    assert ss.index()['is_history_b']
-    assert ss.shorthand_id() == pg.shorthand_id() + '#2'
-    assert ss.title == pg.title
-    assert ss.text == pg.text
-    pytest.raises(IndexError, pg.get_version, 42)
-    pg.revert(1)
-    pg.commit()
-    ThreadLocalORMSession.flush_all()
-    assert ss.text != pg.text
-    assert pg.history().count() == 3
-
-
-@with_setup(setup_method)
-def test_messages_unknown_lookup():
-    from bson import ObjectId
-    m = Checkmessage()
-    m.author_id = ObjectId()  # something new
-    assert isinstance(m.author(), M.User), type(m.author())
-    assert m.author() == M.User.anonymous()
-
-
-@with_setup(setup_method)
-@patch('allura.model.artifact.datetime')
-def test_last_updated(_datetime):
-    c.project.last_updated = datetime(2014, 1, 1)
-    _datetime.utcnow.return_value = datetime(2014, 1, 2)
-    WM.Page(title='TestPage1')
-    ThreadLocalORMSession.flush_all()
-    assert c.project.last_updated == datetime(2014, 1, 2)
-
-
-@with_setup(setup_method)
-@patch('allura.model.artifact.datetime')
-def test_last_updated_disabled(_datetime):
-    c.project.last_updated = datetime(2014, 1, 1)
-    _datetime.utcnow.return_value = datetime(2014, 1, 2)
-    try:
-        M.artifact_orm_session._get().skip_last_updated = True
+        ThreadLocalORMSession.flush_all()
+        ss = pg.get_version(1)
+        assert ss.author.logged_ip == '1.1.1.1'
+        assert ss.index()['is_history_b']
+        assert ss.shorthand_id() == pg.shorthand_id() + '#1'
+        assert ss.title == pg.title
+        assert ss.text != pg.text
+        ss = pg.get_version(-1)
+        assert ss.index()['is_history_b']
+        assert ss.shorthand_id() == pg.shorthand_id() + '#2'
+        assert ss.title == pg.title
+        assert ss.text == pg.text
+        pytest.raises(IndexError, pg.get_version, 42)
+        pg.revert(1)
+        pg.commit()
+        ThreadLocalORMSession.flush_all()
+        assert ss.text != pg.text
+        assert pg.history().count() == 3
+
+    def test_messages_unknown_lookup(self):
+        from bson import ObjectId
+        m = Checkmessage()
+        m.author_id = ObjectId()  # something new
+        assert isinstance(m.author(), M.User), type(m.author())
+        assert m.author() == M.User.anonymous()
+
+    @patch('allura.model.artifact.datetime')
+    def test_last_updated(self, _datetime):
+        c.project.last_updated = datetime(2014, 1, 1)
+        _datetime.utcnow.return_value = datetime(2014, 1, 2)
         WM.Page(title='TestPage1')
         ThreadLocalORMSession.flush_all()
-        assert c.project.last_updated == datetime(2014, 1, 1)
-    finally:
-        M.artifact_orm_session._get().skip_last_updated = False
-
-
-@with_setup(setup_method)
-def test_get_discussion_thread_dupe():
-    artif = WM.Page(title='TestSomeArtifact')
-    thr1 = artif.get_discussion_thread()[0]
-    thr1.post('thr1-post1')
-    thr1.post('thr1-post2')
-    thr2 = M.Thread.new(ref_id=thr1.ref_id)
-    thr2.post('thr2-post1')
-    thr2.post('thr2-post2')
-    thr2.post('thr2-post3')
-    thr3 = M.Thread.new(ref_id=thr1.ref_id)
-    thr3.post('thr3-post1')
-    thr4 = M.Thread.new(ref_id=thr1.ref_id)
-
-    thread_q = M.Thread.query.find(dict(ref_id=artif.index_id()))
-    assert thread_q.count() == 4
-
-    thread = artif.get_discussion_thread()[0]  # force cleanup
-    threads = thread_q.all()
-    assert len(threads) == 1
-    assert len(thread.posts) == 6
-    assert not any(p.deleted for p in thread.posts)  # normal thread deletion 
propagates to children, make sure that doesn't happen
-
-
-def test_snapshot_clear_user_data():
-    s = M.Snapshot(author={'username': 'johndoe',
-                           'display_name': 'John Doe',
-                           'logged_ip': '1.2.3.4'})
-    s.clear_user_data()
-    assert s.author == {'username': '',
+        assert c.project.last_updated == datetime(2014, 1, 2)
+
+    @patch('allura.model.artifact.datetime')
+    def test_last_updated_disabled(self, _datetime):
+        c.project.last_updated = datetime(2014, 1, 1)
+        _datetime.utcnow.return_value = datetime(2014, 1, 2)
+        try:
+            M.artifact_orm_session._get().skip_last_updated = True
+            WM.Page(title='TestPage1')
+            ThreadLocalORMSession.flush_all()
+            assert c.project.last_updated == datetime(2014, 1, 1)
+        finally:
+            M.artifact_orm_session._get().skip_last_updated = False
+
+    def test_get_discussion_thread_dupe(self):
+        artif = WM.Page(title='TestSomeArtifact')
+        thr1 = artif.get_discussion_thread()[0]
+        thr1.post('thr1-post1')
+        thr1.post('thr1-post2')
+        thr2 = M.Thread.new(ref_id=thr1.ref_id)
+        thr2.post('thr2-post1')
+        thr2.post('thr2-post2')
+        thr2.post('thr2-post3')
+        thr3 = M.Thread.new(ref_id=thr1.ref_id)
+        thr3.post('thr3-post1')
+        thr4 = M.Thread.new(ref_id=thr1.ref_id)
+
+        thread_q = M.Thread.query.find(dict(ref_id=artif.index_id()))
+        assert thread_q.count() == 4
+
+        thread = artif.get_discussion_thread()[0]  # force cleanup
+        threads = thread_q.all()
+        assert len(threads) == 1
+        assert len(thread.posts) == 6
+        # normal thread deletion propagates to children, make sure that 
doesn't happen
+        assert not any(p.deleted for p in thread.posts)
+
+    def test_snapshot_clear_user_data(self):
+        s = M.Snapshot(author={'username': 'johndoe',
+                               'display_name': 'John Doe',
+                               'logged_ip': '1.2.3.4'})
+        s.clear_user_data()
+        assert s.author == {'username': '',
                             'display_name': '',
                             'logged_ip': None,
-                            'id': None,
-                            }
-
-
-@with_setup(setup_method)
-def test_snapshot_from_username():
-    s = M.Snapshot(author={'username': 'johndoe',
-                           'display_name': 'John Doe',
-                           'logged_ip': '1.2.3.4'})
-    s = M.Snapshot(author={'username': 'johnsmith',
-                           'display_name': 'John Doe',
-                           'logged_ip': '1.2.3.4'})
-    ThreadLocalORMSession.flush_all()
-    assert len(M.Snapshot.from_username('johndoe')) == 1
-
-
-def test_feed_clear_user_data():
-    f = M.Feed(author_name='John Doe',
+                            'id': None}
+
+    def test_snapshot_from_username(self):
+        s = M.Snapshot(author={'username': 'johndoe',
+                               'display_name': 'John Doe',
+                               'logged_ip': '1.2.3.4'})
+        s = M.Snapshot(author={'username': 'johnsmith',
+                               'display_name': 'John Doe',
+                               'logged_ip': '1.2.3.4'})
+        ThreadLocalORMSession.flush_all()
+        assert len(M.Snapshot.from_username('johndoe')) == 1
+
+    def test_feed_clear_user_data(self):
+        f = M.Feed(author_name='John Doe',
+                   author_link='/u/johndoe/',
+                   title='Something')
+        f.clear_user_data()
+        assert f.author_name == ''
+        assert f.author_link == ''
+        assert f.title == 'Something'
+
+        f = M.Feed(author_name='John Doe',
+                   author_link='/u/johndoe/',
+                   title='Home Page modified by John Doe')
+        f.clear_user_data()
+        assert f.author_name == ''
+        assert f.author_link == ''
+        assert f.title == 'Home Page modified by <REDACTED>'
+
+    def test_feed_from_username(self):
+        M.Feed(author_name='John Doe',
                author_link='/u/johndoe/',
                title='Something')
-    f.clear_user_data()
-    assert f.author_name == ''
-    assert f.author_link == ''
-    assert f.title == 'Something'
-
-    f = M.Feed(author_name='John Doe',
-               author_link='/u/johndoe/',
-               title='Home Page modified by John Doe')
-    f.clear_user_data()
-    assert f.author_name == ''
-    assert f.author_link == ''
-    assert f.title == 'Home Page modified by <REDACTED>'
-
-
-@with_setup(setup_method)
-def test_feed_from_username():
-    M.Feed(author_name='John Doe',
-           author_link='/u/johndoe/',
-           title='Something')
-    M.Feed(author_name='John Smith',
-           author_link='/u/johnsmith/',
-           title='Something')
-    ThreadLocalORMSession.flush_all()
-    assert len(M.Feed.from_username('johndoe')) == 1
-
-
-@with_setup(setup_method)
-def test_subscribed():
-    pg = WM.Page(title='TestPage4a')
-    assert pg.subscribed(include_parents=True)  # tool is subscribed to admins 
by default
-    assert not pg.subscribed(include_parents=False)
-
-
-@with_setup(setup_method)
-def test_subscribed_no_tool_sub():
-    pg = WM.Page(title='TestPage4b')
-    M.Mailbox.unsubscribe(user_id=c.user._id,
-                          project_id=c.project._id,
-                          app_config_id=c.app.config._id)
-    pg.subscribe()
-    assert pg.subscribed(include_parents=True)
-    assert pg.subscribed(include_parents=False)
-
-
-@with_setup(setup_method)
-def test_not_subscribed():
-    pg = WM.Page(title='TestPage4c')
-    M.Mailbox.unsubscribe(user_id=c.user._id,
-                          project_id=c.project._id,
-                          app_config_id=c.app.config._id)
-    assert not pg.subscribed(include_parents=True)
-    assert not pg.subscribed(include_parents=False)
+        M.Feed(author_name='John Smith',
+               author_link='/u/johnsmith/',
+               title='Something')
+        ThreadLocalORMSession.flush_all()
+        assert len(M.Feed.from_username('johndoe')) == 1
+
+    def test_subscribed(self):
+        pg = WM.Page(title='TestPage4a')
+        assert pg.subscribed(include_parents=True)  # tool is subscribed to 
admins by default
+        assert not pg.subscribed(include_parents=False)
+
+    def test_subscribed_no_tool_sub(self):
+        pg = WM.Page(title='TestPage4b')
+        M.Mailbox.unsubscribe(user_id=c.user._id,
+                              project_id=c.project._id,
+                              app_config_id=c.app.config._id)
+        pg.subscribe()
+        assert pg.subscribed(include_parents=True)
+        assert pg.subscribed(include_parents=False)
+
+    def test_not_subscribed(self):
+        pg = WM.Page(title='TestPage4c')
+        M.Mailbox.unsubscribe(user_id=c.user._id,
+                              project_id=c.project._id,
+                              app_config_id=c.app.config._id)
+        assert not pg.subscribed(include_parents=True)
+        assert not pg.subscribed(include_parents=False)
diff --git a/Allura/allura/tests/model/test_auth.py 
b/Allura/allura/tests/model/test_auth.py
index 6f9a3874e..7b6364938 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -72,11 +72,11 @@ class TestAuth:
 
         assert M.EmailAddress.get(email='[email protected]') == addr
         assert M.EmailAddress.get(email='[email protected]') == addr
-        assert M.EmailAddress.get(email='[email protected]') == None
-        assert M.EmailAddress.get(email=None) == None
+        assert M.EmailAddress.get(email='[email protected]') is None
+        assert M.EmailAddress.get(email=None) is None
         assert M.EmailAddress.get(email='[email protected]') == nobody
         # invalid email returns None, but not [email protected] as before
-        assert M.EmailAddress.get(email='invalid') == None
+        assert M.EmailAddress.get(email='invalid') is None
 
         assert M.EmailAddress.find(dict(email='[email protected]')).all() == 
[addr]
         assert M.EmailAddress.find(dict(email='[email protected]')).all() == 
[addr]
@@ -87,21 +87,21 @@ class TestAuth:
         assert M.EmailAddress.find(dict(email='invalid')).all() == []
 
     def test_email_address_canonical(self):
-        assert (M.EmailAddress.canonical('[email protected]') ==
-                    '[email protected]')
-        assert (M.EmailAddress.canonical('[email protected]') ==
-                    '[email protected]')
-        assert (M.EmailAddress.canonical('I Am Nobody <[email protected]>') ==
-                    '[email protected]')
-        assert (M.EmailAddress.canonical('  [email protected]\t') ==
-                    '[email protected]')
-        assert (M.EmailAddress.canonical('I Am@Nobody <[email protected]> ') 
==
-                    '[email protected]')
-        assert (M.EmailAddress.canonical(' No@body <no@[email protected]> ') ==
-                    'no@[email protected]')
-        assert (M.EmailAddress.canonical('no@[email protected]') ==
-                    'no@[email protected]')
-        assert M.EmailAddress.canonical('invalid') == None
+        assert M.EmailAddress.canonical('[email protected]') == \
+               '[email protected]'
+        assert M.EmailAddress.canonical('[email protected]') == \
+               '[email protected]'
+        assert M.EmailAddress.canonical('I Am Nobody <[email protected]>') == 
\
+               '[email protected]'
+        assert M.EmailAddress.canonical('  [email protected]\t') == \
+               '[email protected]'
+        assert M.EmailAddress.canonical('I Am@Nobody <[email protected]> ') 
== \
+               '[email protected]'
+        assert M.EmailAddress.canonical(' No@body <no@[email protected]> ') == \
+               'no@[email protected]'
+        assert M.EmailAddress.canonical('no@[email protected]') == \
+               'no@[email protected]'
+        assert M.EmailAddress.canonical('invalid') is None
 
     def test_email_address_send_verification_link(self):
         addr = M.EmailAddress(email='[email protected]',
@@ -125,7 +125,7 @@ class TestAuth:
         p.deleted = True
         ThreadLocalORMSession.flush_all()
         assert ({p.shortname for p in c.user.my_projects()} ==
-                    {'test', 'u/test-admin', 'adobe-1', '--init--'})
+                {'test', 'u/test-admin', 'adobe-1', '--init--'})
         u = M.User.register(dict(
             username='nosetest-user'))
         ThreadLocalORMSession.flush_all()
@@ -178,13 +178,13 @@ class TestAuth:
         u1 = M.User.register(dict(username='abc1'), make_project=False)
         u2 = M.User.register(dict(username='abc2'), make_project=False)
         addr1 = M.EmailAddress(email='[email protected]', confirmed=True,
-                            claimed_by_user_id=u1._id)
+                               claimed_by_user_id=u1._id)
         addr2 = M.EmailAddress(email='[email protected]', confirmed=True,
-                            claimed_by_user_id=u2._id)
+                               claimed_by_user_id=u2._id)
         # both users are disabled
         u1.disabled, u2.disabled = True, True
         ThreadLocalORMSession.flush_all()
-        assert M.User.by_email_address('[email protected]') == None
+        assert M.User.by_email_address('[email protected]') is None
         assert log.warn.call_count == 0
 
         # only u2 is active
@@ -205,7 +205,7 @@ class TestAuth:
                                 claimed_by_user_id=u1._id)
         ThreadLocalORMSession.flush_all()
         assert M.User.by_email_address('[email protected]') == u1
-        assert M.User.by_email_address('invalid') == None
+        assert M.User.by_email_address('invalid') is None
 
     def test_user_equality(self):
         assert M.User.by_username('test-user') == 
M.User.by_username('test-user')
@@ -214,7 +214,7 @@ class TestAuth:
 
         assert M.User.by_username('test-user') != 
M.User.by_username('test-admin')
         assert M.User.by_username('test-user') != M.User.anonymous()
-        assert M.User.anonymous() != None
+        assert M.User.anonymous() is not None
         assert M.User.anonymous() != 12345
         assert M.User.anonymous() != M.User()
 
@@ -280,9 +280,9 @@ class TestAuth:
         ThreadLocalORMSession.flush_all()
         g.credentials.clear()
         assert ({p.shortname for p in c.user.my_projects()} ==
-                    {'test', 'test2', 'u/test-admin', 'adobe-1', '--init--'})
+                {'test', 'test2', 'u/test-admin', 'adobe-1', '--init--'})
         assert ({p.shortname for p in 
c.user.my_projects_by_role_name('Admin')} ==
-                    {'test', 'u/test-admin', 'adobe-1', '--init--'})
+                {'test', 'u/test-admin', 'adobe-1', '--init--'})
 
     @td.with_user_project('test-admin')
     def test_user_projects_unnamed(self):
@@ -319,14 +319,14 @@ class TestAuth:
         setup_functional_test()
         c.user = M.User.by_username('test-admin')
 
-        assert c.user.last_access['session_date'] == None
-        assert c.user.last_access['session_ip'] == None
-        assert c.user.last_access['session_ua'] == None
+        assert c.user.last_access['session_date'] is None
+        assert c.user.last_access['session_ip'] is None
+        assert c.user.last_access['session_ua'] is None
 
         req = Mock(headers={'User-Agent': 'browser'}, remote_addr='addr')
         c.user.track_active(req)
         c.user = M.User.by_username(c.user.username)
-        assert c.user.last_access['session_date'] != None
+        assert c.user.last_access['session_date'] is not None
         assert c.user.last_access['session_ip'] == 'addr'
         assert c.user.last_access['session_ua'] == 'browser'
 
@@ -365,7 +365,7 @@ class TestAuth:
         assert idx['email_addresses_t'] == 'email1 email2'
         assert idx['email_address_s'] == 'email2'
         assert 'last_password_updated_dt' in idx
-        assert idx['disabled_b'] == False
+        assert idx['disabled_b'] is False
         assert 'results_per_page_i' in idx
         assert 'email_format_s' in idx
         assert 'disable_user_messages_b' in idx
@@ -426,6 +426,11 @@ class TestAuth:
 @with_nose_compatibility
 class TestAuditLog:
 
+    @classmethod
+    def setup_class(cls):
+        setup_basic_test()
+        setup_global_objects()
+
     def test_message_html(self):
         al = h.auditlog_user('our message <script>alert(1)</script>')
         assert al.message == textwrap.dedent('''\

Reply via email to