/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-06 22:17:10 UTC
  • mto: This revision was merged to the branch mainline in revision 4940.
  • Revision ID: john@arbash-meinel.com-20100106221710-3shwzqvrfne5mlyi
Revert all of the extension code.

Instead, just stick with os.utime. It is *much* simpler, and I couldn't
find a performance impact of not using it.
The one small difference is that you should call it after closing
the file, but that is reasonable to do anyway.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
2004
2004
        del os.environ['COLUMNS']
2005
2005
        # Whatever the result is, if we don't raise an exception, it's ok.
2006
2006
        osutils.terminal_width()
2007
 
 
2008
 
 
2009
 
class TestFSetMtime(tests.TestCaseInTempDir):
2010
 
 
2011
 
    def _check_fset_mtime(self, func):
2012
 
        f = open('test', 'wb')
2013
 
        try:
2014
 
            mtime = os.fstat(f.fileno()).st_mtime
2015
 
            new_mtime = mtime - 20
2016
 
            func(f, new_mtime)
2017
 
        finally:
2018
 
            f.close()
2019
 
        self.assertNotEqual(mtime, new_mtime)
2020
 
        set_mtime = os.lstat('test').st_mtime
2021
 
        # We don't guarantee any better than 2s resolution, due to timestamp
2022
 
        # precision limitations on older filesystems such as FAT, but try to
2023
 
        # use functions that have at least microsecond resolution (1us on
2024
 
        # POSIX, 100ns on Windows)
2025
 
        self.assertTrue(abs(set_mtime - new_mtime) < 2.0,
2026
 
            "%r != %r within two seconds" % (new_mtime, set_mtime))
2027
 
 
2028
 
    def test_fset_mtime(self):
2029
 
        self._check_fset_mtime(osutils.fset_mtime)
2030
 
 
2031
 
    def test__utime_fset_mtime(self):
2032
 
        self._check_fset_mtime(osutils._utime_fset_mtime)