Exemple #1
0
    from io import StringIO

if platform.python_version() < '2.7':
    import unittest2 as unittest
else:
    import unittest

try:
    import termios as _termios
except ImportError:
    _termios = None

import helpers
from term2048 import keypress as kp

keypress = kp._getRealModule()

fno = sys.stdin.fileno()


class FakeStdin(StringIO):
    def fileno(self):
        return fno


class TestKeypress(unittest.TestCase):
    def _pushChars(self, *chars):
        """helper. Add chars in the fake stdin"""
        sys.stdin.write(''.join(map(chr, chars)))
        sys.stdin.seek(0)
else:
    from io import StringIO

if platform.python_version() < '2.7':
    import unittest2 as unittest
else:
    import unittest

try:
    import termios as _termios
except ImportError:
    _termios = None

import helpers
from term2048 import keypress as kp
keypress = kp._getRealModule()

fno = sys.stdin.fileno()


class FakeStdin(StringIO):
    def fileno(self):
        return fno


class TestKeypress(unittest.TestCase):

    def _pushChars(self, *chars):
        """helper. Add chars in the fake stdin"""
        sys.stdin.write(''.join(map(chr, chars)))
        sys.stdin.seek(0)
Exemple #3
0
# -*- coding: UTF-8 -*-
try:
    import unittest2 as unittest
except ImportError:
    import unittest

import sys
import platform

if platform.python_version() < '3.0':
    from StringIO import StringIO
else:
    from io import StringIO

from term2048 import keypress
keypress = keypress._getRealModule()

fno = sys.stdin.fileno()

class FakeStdin(StringIO):
    def fileno(self):
        return fno

class TestKeypress(unittest.TestCase):

    def _pushChars(self, *chars):
        """helper. Add chars in the fake stdin"""
        sys.stdin.write(''.join(map(chr, chars)))
        sys.stdin.seek(0)

    def _pushArrowKey(self, code):