mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Tests for writing non-unicode entries on prompt
This commit is contained in:
parent
acf41a153a
commit
43f1166ecf
2 changed files with 12 additions and 6 deletions
|
@ -59,3 +59,10 @@ Feature: Zapped bugs should stay dead.
|
|||
2014-04-24 09:00 Ran 6.2 miles today in 1:02:03.
|
||||
| I'm feeling sore because I forgot to stretch.
|
||||
"""
|
||||
|
||||
Scenario: Writing an entry at the prompt with non-ascii characters
|
||||
# https://github.com/maebert/jrnl/issues/295
|
||||
Given we use the config "basic.json"
|
||||
When we run "jrnl" and enter "Crème brûlée & Mötorhead"
|
||||
Then we should get no error
|
||||
and the journal should contain "Crème brûlée & Mötorhead"
|
||||
|
|
|
@ -2,9 +2,8 @@ from behave import *
|
|||
from jrnl import cli, Journal, util
|
||||
from dateutil import parser as date_parser
|
||||
import os
|
||||
import sys
|
||||
import codecs
|
||||
import json
|
||||
import pytz
|
||||
import keyring
|
||||
keyring.set_keyring(keyring.backends.file.PlaintextKeyring())
|
||||
try:
|
||||
|
@ -30,7 +29,7 @@ def _parse_args(command):
|
|||
def read_journal(journal_name="default"):
|
||||
with open(cli.CONFIG_PATH) as config_file:
|
||||
config = json.load(config_file)
|
||||
with open(config['journals'][journal_name]) as journal_file:
|
||||
with codecs.open(config['journals'][journal_name], 'r', 'utf-8') as journal_file:
|
||||
journal = journal_file.read()
|
||||
return journal
|
||||
|
||||
|
@ -57,7 +56,7 @@ def run_with_input(context, command, inputs=None):
|
|||
buffer = StringIO(text.strip())
|
||||
util.STDIN = buffer
|
||||
try:
|
||||
cli.run(args or None)
|
||||
cli.run(args)
|
||||
context.exit_status = 0
|
||||
except SystemExit as e:
|
||||
context.exit_status = e.code
|
||||
|
@ -66,7 +65,7 @@ def run_with_input(context, command, inputs=None):
|
|||
def run(context, command):
|
||||
args = _parse_args(command)
|
||||
try:
|
||||
cli.run(args or None)
|
||||
cli.run(args)
|
||||
context.exit_status = 0
|
||||
except SystemExit as e:
|
||||
context.exit_status = e.code
|
||||
|
@ -184,7 +183,7 @@ def config_var(context, key, value, journal=None):
|
|||
@then('the journal should have {number:d} entry')
|
||||
@then('journal "{journal_name}" should have {number:d} entries')
|
||||
@then('journal "{journal_name}" should have {number:d} entry')
|
||||
def check_journal_content(context, number, journal_name="default"):
|
||||
def check_num_entries(context, number, journal_name="default"):
|
||||
journal = open_journal(journal_name)
|
||||
assert len(journal.entries) == number
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue