Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite fails because of IndentationError with interpy #3

Open
pcflmb opened this issue Jul 30, 2015 · 1 comment
Open

Test suite fails because of IndentationError with interpy #3

pcflmb opened this issue Jul 30, 2015 · 1 comment

Comments

@pcflmb
Copy link

pcflmb commented Jul 30, 2015

If I use interpy in my testing suite and run python -m tabnanny [file] it doesn't show any errors. But when i run nosetests [file] I get an IndentationError:

E
======================================================================
ERROR: Failure: IndentationError (unindent does not match any outer indentation level (server_communication_test.py, line 19))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/brendanberman/.pyenv/versions/2.7.10/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/Users/brendanberman/.pyenv/versions/2.7.10/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/Users/brendanberman/.pyenv/versions/2.7.10/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/xxx/tests/server/server_communication_test.py", line 19
    websocket_testing_port = 9876
                                ^
IndentationError: unindent does not match any outer indentation level

----------------------------------------------------------------------
Ran 1 test in 0.006s

FAILED (errors=1)
# coding: interpy

__author__ = 'pcflmb'

import unittest
import os
from nose.tools import *

import cherrypy
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
from ws4py.websocket import EchoWebSocket


class ServerCommunicationTest(unittest.TestCase):
    """
    Test to make sure our server is correctly createing a websocket, 
    receiving data, and reconnecting on dropped connections.
    """

    websocket_testing_port = 9876

    @classmethod
    def setup_class(self):
        cherrypy.config.update({'server.socket_port': ServerCommunicationTest.websocket_testing_port})
        WebSocketPlugin(cherrypy.engine).subscribe()
        cherrypy.tools.websocket = WebSocketTool()
        cherrypy.quickstart(Root(), '/', config={'/ws': {'tools.websocket.on': True,
                                                         'tools.websocket.handler_cls': EchoWebSocket}})
    @classmethod
    def teardown_class(self):
        pass

    def test_websocket_connecting(self):
        websocket_client = ServerCommunication("ws://localhost:#{ServerCommunicationTest.websocket_testing_port}/ws")

    def test_websocket_connecting(self):
        pass

class Root(object):
    @cherrypy.expose
    def index(self):
        return 'some HTML with a websocket javascript connection'

    @cherrypy.expose
    def ws(self):
        # you can access the class instance through
        handler = cherrypy.request.ws_handler
@tagatac
Copy link

tagatac commented Nov 1, 2015

Similar issue trying to execute a simple for loop:

#!/usr/bin/env python
# coding: interpy
import psycopg2, random

NUM_ACCOUNTS = 5

conn = psycopg2.connect("dbname=pgbench user=tag")
cur = conn.cursor()
for account in range(NUM_ACCOUNTS):
    balance = random.randrange(1000)
    cur.execute("UPDATE pgbench_accounts SET abalance = #{balance} WHERE aid = #{account+1};")
conn.commit()
cur.close()
conn.close()

Error:

$ ./randomizedb.py 
  File "./randomizedb.py", line 11
    cur.execute(                                                                             "UPDATE pgbench_accounts SET abalance = "+unicode(balance)+" WHERE aid = "+unicode(account+1 )+";"                                                                                       )
                                                                                                                                                                                                                                                                                      ^
IndentationError: unindent does not match any outer indentation level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants