<commit_before>import os
import shutil

import pytest

from LiSE.engine import Engine
from LiSE.examples.kobold import inittest



def test_keyframe_load_init(tempdir):
    """Can load a keyframe at start of branch, including locations"""
    eng = Engine(tempdir)
    inittest(eng)
    eng.branch = 'new'
    eng.snap_keyframe()
    eng.close()
    eng = Engine(tempdir)
    assert 'kobold' in eng.character['physical'].thing
    assert (0, 0) in eng.character['physical'].place
    assert (0, 1) in eng.character['physical'].portal[0, 0]
    eng.close()


def test_multi_keyframe(tempdir):
    eng = Engine(tempdir)
    inittest(eng, kobold_pos=(9, 9))
    eng.snap_keyframe()
    tick0 = eng.tick
    eng.turn = 1
    eng.character['physical'].thing['kobold']['location'] = (3, 3)
    eng.snap_keyframe()
    tick1 = eng.tick
    eng.close()
    eng = Engine(tempdir)
    eng._load_at('trunk', 0, tick0+1)
    assert eng._things_cache.keyframe['physical']['trunk'][0][tick0]\
           != eng._things_cache.keyframe['physical']['trunk'][1][tick1]<commit_msg>Make test_multi_keyframe demonstrate what it's supposed to<commit_after>import os
import shutil

import pytest

from LiSE.engine import Engine
from LiSE.examples.kobold import inittest



def test_keyframe_load_init(tempdir):
    """Can load a keyframe at start of branch, including locations"""
    eng = Engine(tempdir)
    inittest(eng)
    eng.branch = 'new'
    eng.snap_keyframe()
    eng.close()
    eng = Engine(tempdir)
    assert 'kobold' in eng.character['physical'].thing
    assert (0, 0) in eng.character['physical'].place
    assert (0, 1) in eng.character['physical'].portal[0, 0]
    eng.close()


def test_multi_keyframe(tempdir):
    eng = Engine(tempdir)
    inittest(eng)
    eng.snap_keyframe()
    tick0 = eng.tick
    eng.turn = 1
    del eng.character['physical'].place[3, 3]
    eng.snap_keyframe()
    tick1 = eng.tick
    eng.close()
    eng = Engine(tempdir)
    eng._load_at('trunk', 0, tick0+1)
    assert eng._nodes_cache.keyframe['physical', ]['trunk'][0][tick0]\
           != eng._nodes_cache.keyframe['physical', ]['trunk'][1][tick1]
{'fraction_non_alphanumeric': 0.13937118723603942, 'fraction_numerical': 0.017832003754106054, 'mean_word_length': 3.696035242290749, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1852430', 'n_tokens_mistral': 753, 'n_tokens_neox': 724, 'n_words': 161}