2

レタスを使用してステップ定義から出力を取得しようとしています。テストを実行すると、同じテストに表示される内容で上書きされる前に、出力が 1 秒間点滅します。ただし、出力でステップが 2 回呼び出されていることがわかります。1つは非常に暗い(ほぼ黒)色で、もう1つは緑または赤です。出力は以下で強調表示されています。 ファントムテスト

デバッグ情報は、このテストではなく、実行中の他のテストに表示されるため、これは頭痛の種です。これを明確に説明するのに苦労していますが、スクリーン キャプチャが要点を説明するのに役立つと思います。各ステップが 1 回だけ呼び出されることを確認する必要がありますが、現在はそうではありません。

これについての助けをいただければ幸いです。

特徴

Feature: Navigation
As a persion looking for information on specific machine
In order to view up to date machine inventory
I should be able to navigate to a individual machine

Background:
    Given the following users exist:
        | username | first_name | last_name | password |
        | johndoe  | John       | Doe       | testpass |
    And the following machines exist:
        | msnbr     | machine_name     | brand_name | brand_slug | division | product_group | machine_type | price | model  | location |
        | 111111    | Router           | Altendorf  | altendorf  | All      | All           | All          | 100   | model7 | Zenith   |
        | 222222    | CNC Router       | Belfab     | belfab     | All      | All           | All          | 200   | model6 | Echo     |
        | 333333    | Saw              | Durst      | durst      | All      | All           | All          | 300   | model5 | Xalpha   |
        | 444444    | Another Router   | Belfab     | belfab     | All      | All           | All          | 250   | model4 | Beta     |
        | 555555    | eh Router        | Belfab     | belfab     | All      | All           | All          | 250   | model4 | Water    |
        | 666666    | Router 6         | Belfab     | belfab     | All      | All           | All          | 250   | model2 | River    |
        | 777777    | Router 8         | Belfab     | belfab     | All      | All           | All          | 250   | model1 | Snake    |
    And I am logged in as "johndoe" with password "testpass"

Scenario: As an executive, I can see all brands
    Given I see "Brand"
    Then I should see "Altendorf"
    And I should see "Belfab"
    And I should see "Durst"
    Then I click "Logout"

Scenario: As an executive, I can navigate into brands
    Given I see "Brand"
    When I click "Belfab"
    Then I should see "5" machines
    And the machines should be in the following order:
        | model  |
        | model2 |
        | model4 |
        | model5 |
        | model6 |
        | model7 |

手順 (フォーマットは少しオフ)

from lettuce import step, world
from lettuce_webdriver.util import assert_true
from django.contrib.auth.models import User
from website.factories import *
from website.models import *

@step(u'the following machines exist:')
def the_following_machines_exist(step):
for machine_hash in step.hashes:
    brand, created = Brand.objects.get_or_create(
        name=machine_hash['brand_name'],
        slug=machine_hash['brand_slug']
    )

    division, created = Division.objects.get_or_create(
        name=machine_hash['division']
    )

    product_group, created = ProductGroup.objects.get_or_create(
        name=machine_hash['product_group']
    )

    machine_type, created = MachineType.objects.get_or_create(
        name=machine_hash['machine_type']
    )

    machine = Machine(
        machine_year = "2000",
        hold_for = "john",
        us_destination = "el paso",
        voltage = "500",
        last_update_on = "January 10",
        port_of_entry = "LAX",
        msnbr = machine_hash['msnbr'],
        description = "Machine description",
        location=machine_hash['location'],
        model=machine_hash['model'],
        age=15,
        price=machine_hash['price'],
        active=True,
        division=division,
        product_group=product_group,
        machine_type=machine_type,
        brand=brand
    )
    machine.save()

@step(u'I should see "([^"]*)" machines')
def i_should_see_n_machines(step, n):
selector = "#left-main ol li"
elements = world.browser.find_elements_by_css_selector(selector)
if len(elements) != int(n):
    raise Exception("Error: Number of machines does not match: %d != %d" % (len(elements), int(n)))

@step(u'the machines should be in the following order:')
def the_machines_should_be_in_the_following_order(step):
selector = "#left-main ol li"
elements = world.browser.find_elements_by_css_selector(selector)
for i in range(0, len(elements)):
    el_text = elements[i].find_element_by_css_selector(".name").text
    if step.hashes[i]['model'] != el_text:
        print "FAIL"
    else:
        print el_text
        print step.hashes[i]['model']

設定

# Django settings for stiles_aml project.
import os.path
root = os.path.dirname(__file__).replace('\\','/')

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = ( *** )

MANAGERS = ADMINS

DATABASES = { *** }

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Detroit'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = root + '/../media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = root + '/../static/'

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    root + "/../shared_static",
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '***'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.request',
    'django.core.context_processors.static',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    # 'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.gzip.GZipMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
)

ROOT_URLCONF = '***_aml.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = '***_aml.wsgi.application'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    root + '/../templates'
)

# Sentry key
SENTRY_DSN = '****'

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'django.contrib.humanize',

    # 3rd party
    'south',
    'debug_toolbar',
    'tastypie',
    'django_extensions',
    'shell_plus',
    'raven.contrib.django',
    'django_nose',
    'lettuce.django',

    # Authored
    'website',
)

# Email settings
EMAIL_HOST = '****'
REQUEST_QUOTE_EMAIL = ['****']
4

0 に答える 0