# Path: datafs/_compat.py
# def open_filelike(filelike, mode='r'):


from datafs._compat import u
from fs.errors import (ResourceNotFoundError, NoMetaError)
import pytest
    archive = api1.create('test_versioned_archive')

    assert archive.versioned, "Archive not versioned, but should be by default"

    assert archive.get_latest_version() is None
    assert len(archive.get_versions()) == 0
    assert archive.get_latest_hash() is None
    assert archive.get_version_hash() is None

    with opener(archive, 'w+', prerelease='alpha') as f:
        f.write(u('test content v0.0.1a1'))

    assert archive.get_latest_version() == '0.0.1a1'
    assert len(archive.get_versions()) == 1
    assert archive.get_latest_hash() is not None
    assert archive.get_version_hash('0.0.1a1') == archive.get_latest_hash()

    with opener(archive, 'r') as f:
        assert u(f.read()) == u('test content v0.0.1a1')

    with opener(archive, 'w+', bumpversion='minor', prerelease='beta') as f:
        f.write(u('test content v0.1b1'))

    assert archive.get_latest_version() == '0.1b1'
    assert len(archive.get_versions()) == 2
    assert archive.get_latest_hash() is not None
    assert archive.get_version_hash('0.0.1a1') != archive.get_latest_hash()
    assert archive.get_version_hash('0.1b1') == archive.get_latest_hash()

    with opener(archive, 'r') as f:

# Path: datafs/_compat.py
# def open_filelike(filelike, mode='r'):


# Path: tests/test_versions.py
from datafs._compat import u
from fs.errors import (ResourceNotFoundError, NoMetaError)
import pytest

    archive = api1.create('test_versioned_archive')

    assert archive.versioned, "Archive not versioned, but should be by default"

    assert archive.get_latest_version() is None
    assert len(archive.get_versions()) == 0
    assert archive.get_latest_hash() is None
    assert archive.get_version_hash() is None

    with opener(archive, 'w+', prerelease='alpha') as f:
        f.write(u('test content v0.0.1a1'))

    assert archive.get_latest_version() == '0.0.1a1'
    assert len(archive.get_versions()) == 1
    assert archive.get_latest_hash() is not None
    assert archive.get_version_hash('0.0.1a1') == archive.get_latest_hash()

    with opener(archive, 'r') as f:
        assert u(f.read()) == u('test content v0.0.1a1')

    with opener(archive, 'w+', bumpversion='minor', prerelease='beta') as f:
        f.write(u('test content v0.1b1'))

    assert archive.get_latest_version() == '0.1b1'
    assert len(archive.get_versions()) == 2
    assert archive.get_latest_hash() is not None
    assert archive.get_version_hash('0.0.1a1') != archive.get_latest_hash()
    assert archive.get_version_hash('0.1b1') == archive.get_latest_hash()

    with opener(archive, 'r') as f:

        assert u(f.read()) == u('test content v0.1b1')