File: fileformatterbase.py

package info (click to toggle)
python-happydoc 2.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,392 kB
  • ctags: 3,479
  • sloc: python: 12,382; makefile: 99; sh: 37
file content (701 lines) | stat: -rw-r--r-- 28,108 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
#!/usr/bin/env python
#
# COPYRIGHT
#
#   Permission to use, copy, modify, and distribute this software and
#   its documentation for any purpose and without fee is hereby
#   granted, provided that the above copyright notice appear in all
#   copies and that both that copyright notice and this permission
#   notice appear in supporting documentation, and that the name of Doug
#   Hellmann not be used in advertising or publicity pertaining to
#   distribution of the software without specific, written prior
#   permission.
# 
# DISCLAIMER
#
#   DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
#   INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
#   NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
#   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
#   OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
#   NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
#   CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# 


"""A base class for file-based formatters for HappyDoc.

"""

__rcs_info__ = {
    #
    #  Creation Information
    #
    'module_name':'$RCSfile: fileformatterbase.py,v $',
    'creator':'Doug Hellmann <doug@hellfly.net>',
    'project':'HappyDoc',
    'created':'Sat, 03-Jun-2000 17:56:22 EDT',
    #
    #  Current Information
    #
    'author':'$Author: doughellmann $',
    'version':'$Revision: 1.10 $',
    'date':'$Date: 2002/08/24 19:51:02 $',
    }
try:
    __version__ = __rcs_info__['version'].split(' ')[1]
except:
    __version__ = '0.0'

#
# Import system modules
#
import os
import string
import types

#
# Import Local modules
#
import happydoclib
import happydoclib.StreamFlushTest as StreamFlushTest

#
# Module
#

    
class FileBasedFormatter(happydoclib.happyformatter.HappyFormatterBase):
    """A base class for file-based formatters for HappyDoc.
    """

    def __init__(self, docSet, filenamePrefix='', **extraNamedParameters):
        """Initialize a FileBasedFormatter.

        Parameters

          docSet -- The documentation set controlling the formatter.
          
          filenamePrefix -- A prefix to append to the base names of
          files and directories being created.  This is useful for
          situations where the names which would be automatically
          generated might cause a name clash or conflict.

          extraNamedParameters -- Parameters specified by name which
          were not supported by a subclass initialization.
          
        """
        #
        # Store parameters
        #
        self._filename_prefix = filenamePrefix
        #
        # Initialize the base class
        #
        apply(happydoclib.happyformatter.HappyFormatterBase.__init__,
              (self, docSet,),
              extraNamedParameters)
        return

    def openOutput(self, name, title1, title2=None):
        "Open the named output destination and give the title."
        happydoclib.path.rmkdir(happydoclib.path.dirname(name))
        f = open(name, 'wt')
        if not hasattr(self, 'open_root_file'):
            self.open_root_file = f
        return f

    def closeOutput(self, output):
        "Close the output handle."
        output.close()
        return

    def fixUpOutputFilename(self, filename):
        """Tweak the filename to remove relative references
        and add the safe prefix.

        Returns a relative path, but without the ./ or ../ at the
        front.  This path will then, usually, be tacked on the end of
        the output path to create a full path.
        """
        happydoclib.TRACE.into('FileBasedFormatter', 'fixUpOutputFilename',
                               filename=filename)
        #
        # Remove preceding slashes to make name relative
        #
        filename = happydoclib.path.removeRelativePrefix(filename)
        happydoclib.TRACE.writeVar(filename_after_remove_relative_prefix=filename)
        #
        # Apply the path prefix, if required
        #
        if self.getFilenamePrefix():
            filename = happydoclib.path.applyPrefixToPath( filename,
                                                           self.getFilenamePrefix())
            happydoclib.TRACE.writeVar(filename_after_apply_prefix=filename)
        happydoclib.TRACE.outof(filename)
        return filename
    
    def getOutputNameForFile(self, filename):
        """Return the base name of the thing to which output should be
        written for a file.

        This is usually a file name, but could be anything understood
        by the formatter as a name.  If infoObject is None, return the
        name for a root node for this formatter.
        """
        happydoclib.TRACE.into('FileBasedFormatter', 'getOutputNameForFile',
                               filename=filename)
        filename = self.fixUpOutputFilename(filename)
        happydoclib.TRACE.writeVar(filename=filename)
        #
        # Set the correct extension for the output file
        #
        extension = self.getFilenameExtension()
        happydoclib.TRACE.writeVar(extension=extension)
        #
        # Build the name
        #
        name = '%s.%s' % (filename, extension)
        happydoclib.TRACE.outof(name)
        return name
    
    def getOutputNameForObject(self, infoObject):
        """Return the base name of the thing to which output should be written
        for an info source.

        This is usually a file name, but could be anything understood
        by the formatter as a name.  If infoObject is None, return the
        name for a root node for this formatter.
        """
        happydoclib.TRACE.into('FileBasedFormatter', 'getOutputNameForObject',
                               infoObject=infoObject)
        
        if type(infoObject) == types.StringType:
            happydoclib.TRACE.write('object is a string')
            name = infoObject
            
        elif type(infoObject) == types.FileType:
            happydoclib.TRACE.write('object is a file')
            name = infoObject.name
            
        elif infoObject is not None:
            happydoclib.TRACE.write('object is an infoObject')
            #name = self.getOutputNameForFile(infoObject.getFullyQualifiedName())
            name = apply(happydoclib.path.join, infoObject.getPath() )
            name = '%s.%s' % (name,  self.getFilenameExtension())
            happydoclib.TRACE.write('file for %s' % infoObject.getName())
            happydoclib.TRACE.write('is %s' % name)
            
        else:
            happydoclib.TRACE.write('object is a root node')
            docset_path = self._docset.getPath()
            if docset_path:
                name = apply(happydoclib.path.join, docset_path )
                name = happydoclib.path.join(name, self.getRootNodeName())
            else:
                name = self.getRootNodeName()
            
        happydoclib.TRACE.outof(name)
        return name


    def getLocalOutputNameForObject(self, infoObject):
        """Return a local reference to base name of the thing to which
        output should be written for an info source.

        This is usually a file name, but could be anything understood
        by the formatter as a name.  If infoObject is None, return the
        name for a root node for this formatter.
        """
        extension = self.getFilenameExtension()
        if infoObject is not None:
            name = '%s.%s' % ( infoObject.getQualifiedName(self.getFilenamePrefix()),
                               extension )
        else:
            name = self.getRootNodeName()
        return name

    def getFullOutputNameForObject(self, infoObject):
        """Get the full name, including path, to the object being output.

        The prefix of the return value should be the output path for
        all documentation.  The rest of the return value will be based
        on the path to the source for the object.
        """
        happydoclib.TRACE.into('FileBasedFormatter', 'getFullOutputNameForObject',
                               infoObject=infoObject)

        #
        # Get the basic output name for the object
        #
        obj_output_name = self.getOutputNameForObject(infoObject)
        #
        # Get the root output directory
        #
        output_base = self._docset.getOutputBaseDirectory()
        #
        # Get the base input directory for the docset
        #
        docset_base_directory = self._docset.getDocsetBaseDirectory()
        
        happydoclib.TRACE.writeVar(obj_output_name=obj_output_name)
        happydoclib.TRACE.writeVar(docset_base_directory=docset_base_directory)
        happydoclib.TRACE.writeVar(output_base=output_base)
        
        if (not infoObject) and docset_base_directory:
            #
            # For a docset root node, just tack the object
            # output name onto the output base directory.
            #
            happydoclib.TRACE.write('ROOT NODE FOR CURRENT DOCSET')
            
            #
            # Now reduce docset_base_minux_prefix by the
            # path of the docset itself, so we don't end
            # up with duplicate subdirectory names.
            #
            docset_path = self._docset.getPath()
            if docset_path:
                happydoclib.TRACE.write('removing docset_path')
                docset_path = apply(os.path.join, docset_path)
                len_docset_path = len(docset_path)
                docset_base_minus_prefix = docset_base_directory[:-len_docset_path]
                base = docset_base_minus_prefix
            else:
                happydoclib.TRACE.write('do not need to remove prefix')
                #base = os.path.join(output_base, docset_base_minus_prefix)
                base = docset_base_directory

            happydoclib.TRACE.writeVar(
                base=base,
                )
                
            #name = happydoclib.path.join(output_base, obj_output_name)
            name = happydoclib.path.join(base, obj_output_name)
            
        elif docset_base_directory:
            #
            # Here we have a real HappyDOM based object.
            #
            happydoclib.TRACE.write('SUBNODE OF DOCSET')
            #obj_parent_path = infoObject.getParent().getPath()
            #obj_parent_path = infoObject.getPath()
            #obj_parent_file_path = apply(os.path.join, obj_parent_path)
            #output_dir = happydoclib.path.join(output_base, obj_parent_file_path)

            if type(infoObject) == types.StringType:
                #
                # What we have is a name for an external documentation
                # file, and that file name should include the full
                # path from the docset root down to the file, so
                # just stick the output base on the front and we're
                # done.
                #
                happydoclib.TRACE.write('FILENAME')
                name = os.path.join(output_base,
                                    infoObject)
                
            else:
                happydoclib.TRACE.write('OBJECT')

                #
                # Determine if there is any path component between the
                # docset base and the output base.
                #
                prefix = happydoclib.path.commonPrefix(docset_base_directory,
                                                       output_base,
                                                       )
                docset_base_minus_prefix = happydoclib.path.removePrefix(
                    docset_base_directory,
                    prefix,
                    )
                happydoclib.TRACE.writeVar(
                    prefix=prefix,
                    docset_base_minus_prefix=docset_base_minus_prefix,
                    )

                #
                # Now reduce docset_base_minux_prefix by the
                # path of the docset itself, so we don't end
                # up with duplicate subdirectory names.
                #
                docset_path = self._docset.getPath()
                if docset_path:
                    happydoclib.TRACE.write('removing docset_path')
                    docset_path = apply(os.path.join, docset_path)
                    len_docset_path = len(docset_path)
                    docset_base_minus_prefix = docset_base_minus_prefix[:-len_docset_path]

                happydoclib.TRACE.writeVar(
                    prefix=prefix,
                    docset_base_minus_prefix=docset_base_minus_prefix,
                    docset_path=docset_path,
                    )

                name = os.path.join(output_base,
                                    docset_base_minus_prefix,
                                    obj_output_name,
                                    )
                #name = happydoclib.path.join(output_base, obj_output_name)
                #name = happydoclib.path.join(docset_base_directory, obj_output_name)
            
        else:
            happydoclib.TRACE.write('OTHER')
            #
            # How can we get here?
            #
            name = self.getOutputNameForObject(infoObject)

        #name = os.path.normpath(name)

        happydoclib.TRACE.outof(name)
        return name

    def getFullOutputNameForFile(self, filename):
        "Get the full name, including path, to the filename to convert."
        if self._docset.getOutputBaseDirectory():
            name = happydoclib.path.join(
                self._docset.getOutputBaseDirectory(),
                self.getOutputNameForFile(filename),
                )
        else:
            name = self.getOutputNameForFile(filename)

        name = os.path.normpath(name)
        
        return name

    def getRootNodeName(self):
        "Return the name of the root node for the documentation tree."
        self._requiredOfSubclass('getRootNodeName')
        return

    def getFilenamePrefix(self):
        "Return the filename prefix value for this formatter instance."
        return self._filename_prefix


class FileFormatterBaseTest(StreamFlushTest.StreamFlushTest):

    output_base_dir = os.sep + os.path.join('tmp', 'fakedocset', 'output')
    if os.name == 'nt':
        output_base_dir_win32 = 'c:\\%s' % output_base_dir[1:]
    
    def setUp(self):
        
        class FakeDocset:

            def getPath(self):
                return [  ]
            
            def getOutputBaseDirectory(self):
                return FileFormatterBaseTest.output_base_dir

            def getDocsetBaseDirectory(self):
                return os.path.join(self.getOutputBaseDirectory(),
                                    'docset', 'base', 'directory')
            
        class FakeDocsetWin32:
            def getOutputBaseDirectory(self):
                return FileFormatterBaseTest.output_base_dir_win32

            def getDocsetBaseDirectory(self):
                return 'c:\\' + os.path.join('docset', 'base', 'directory')

        class TestFormatter(FileBasedFormatter):
            def getFilenameExtension(self):
                return 'test'
            def getRootNodeName(self):
                return 'index.test'
            
        self.formatter = TestFormatter(FakeDocset())
        self.formatter_win32 = TestFormatter(FakeDocsetWin32())
        return

    def testFixUpOutputFilenameFromRoot(self):
        expected = os.sep + os.path.join('fix', 'up', 'filename')
        actual = self.formatter.fixUpOutputFilename(
            os.sep + os.path.join('fix', 'up', 'filename')
            )
        assert expected == actual, \
               'Fixed filenames do not match ("%s" vs. "%s").' % (expected, actual)
        return

    if os.name == 'nt':
        def testFixUpOutputFilenameFromRootWin32(self):
            expected = 'c:\\' + os.path.join('fix', 'up', 'filename')
            actual = self.formatter.fixUpOutputFilename(
                'c:\\' + os.path.join('fix', 'up', 'filename')
                )
            assert expected == actual, \
                   'Fixed filenames do not match ("%s" vs. "%s").' % (expected, actual)
            return

    def testFixUpOutputFilenameParentDir(self):
        expected = os.path.join('fix', 'up', 'filename')
        actual = self.formatter.fixUpOutputFilename(
            os.path.join(os.pardir, 'fix', 'up', 'filename')
            )
        assert expected == actual, \
               'Fixed filenames do not match ("%s" vs. "%s").' % (expected, actual)
        return

    def testFixUpOutputFilenameCurrentDir(self):
        expected = os.path.join('fix', 'up', 'filename')
        actual = self.formatter.fixUpOutputFilename(
            os.path.join(os.curdir, 'fix', 'up', 'filename')
            )
        assert expected == actual, \
               'Fixed filenames do not match ("%s" vs. "%s").' % (expected, actual)
        return
            
    def testGetOutputNameForFileAtRoot(self):
        filename = 'filename.py'
        expected = '%s.%s' % (filename, 'test')
        actual = self.formatter.getOutputNameForFile(filename)
        assert expected == actual, \
               'Filenames do not match ("%s" vs. "%s").' % (expected, actual)
        return
            
    def testGetOutputNameForFile(self):
        filename = 'TestCases/test_package_summaries/FromReadme/README.txt'
        expected = '%s.%s' % (filename, 'test')
        actual = self.formatter.getOutputNameForFile(filename)
        assert expected == actual, \
               'Filenames do not match ("%s" vs. "%s").' % (expected, actual)
        return
            
    def testGetFullOutputNameForFileName(self):
        filename = 'TestCases/test_package_summaries/FromReadme/README.txt'
        expected = os.path.join(self.output_base_dir, '%s.%s' % (filename, 'test'))
        actual = self.formatter.getFullOutputNameForFile(filename)
        assert expected == actual, \
               'Filenames do not match ("%s" vs. "%s").' % (expected, actual)
        return
            
##    def testGetFullOutputNameForFileObject(self):
##        filename = 'TestCases/test_package_summaries/FromReadme/README.txt'
##        expected = os.path.join(self.output_base_dir, 'docset', 'base', 'directory', filename)
##        actual = self.formatter.getFullOutputNameForObject(filename)
##        assert expected == actual, \
##               ('Filenames do not match\n'
##                'Expected: "%s"\n'
##                'Got:      "%s"' % (expected, actual)
##                )
##        return

    def testGetOutputNameForObjectNone(self):
        info_obj = None
        expected = 'index.test'
        actual = self.formatter.getOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match ("%s" vs "%s")' % \
               (expected, actual)
        return

    def testGetOutputNameForObjectString(self):
        info_obj = 'filename.test'
        expected = 'filename.test'
        actual = self.formatter.getOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match ("%s" vs "%s")' % \
               (expected, actual)
        return

    def testGetOutputNameForObjectFile(self):
        info_obj = open('tmpfile.test', 'wt')
        expected = 'tmpfile.test'
        actual = self.formatter.getOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match ("%s" vs "%s")' % \
               (expected, actual)
        return

    def testGetOutputNameForObjectFullyQualifiedNameRoot(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        info_obj = FakeInfoObj('myfake', None, 'filename.py', [])
        expected = 'myfake.test'
        actual = self.formatter.getOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match (\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return

    def testGetOutputNameForObjectFullyQualifiedNameOneParent(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        parent_obj = FakeInfoObj('myfakeparent', None, 'parent', [])
        info_obj = FakeInfoObj('myfake', parent_obj, 'filename.py', [])
        expected = 'myfakeparent/myfake.test'
        actual = self.formatter.getOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match (\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return

    def testGetOutputNameForObjectFullyQualifiedNameMultipleParents(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        one = FakeInfoObj('one', None, 'parent', [])
        two = FakeInfoObj('two', one, 'parent', [])
        three = FakeInfoObj('three', two, 'parent', [])
        info_obj = FakeInfoObj('myfake', three, 'filename.py', [])
        expected = os.path.join('one', 'two', 'three', 'myfake.test')
        actual = self.formatter.getOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match (\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return

    def testGetFullOutputNameForObjectFullyQualifiedNameMultipleParents(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        one = FakeInfoObj('one', None, 'parent', [])
        two = FakeInfoObj('two', one, 'parent', [])
        three = FakeInfoObj('three', two, 'parent', [])
        info_obj = FakeInfoObj('myfake', three, 'filename.py', [])
        expected = os.path.join(self.output_base_dir,
                                'docset', 'base', 'directory', 'one', 'two', 'three', 'myfake.test')
        actual = self.formatter.getFullOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match (\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return

    def testGetLocalOutputNameForObjectFullyQualifiedNameRoot(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        info_obj = FakeInfoObj('myfake', None, 'filename.py', [])
        expected = 'filename.py.test'
        actual = self.formatter.getLocalOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match ("%s" vs "%s")' % \
               (expected, actual)
        return

    def testGetLocalOutputNameForObjectFullyQualifiedNameOneParent(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        parent_obj = FakeInfoObj('myfakeparent', None, 'parent', [])
        info_obj = FakeInfoObj('myfake', parent_obj, 'filename.py', [])
        expected = 'parent_myfake.test'
        actual = self.formatter.getLocalOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match ("%s" vs "%s")' % \
               (expected, actual)
        return

    def testGetFullOutputNameForObjectFullyQualifiedNameRoot(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        info_obj = FakeInfoObj('filename', None, 'filename.py', [])
        expected = os.sep + os.path.join('tmp', 'fakedocset', 'output',
                                         'docset', 'base', 'directory',
                                         'filename.test'
                                         )
        actual = self.formatter.getFullOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match\n(\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return

    if os.name == 'nt':    
        def testGetFullOutputNameForObjectFullyQualifiedNameRootWin32(self):
            import happydoclib
            import happydoclib.happydom
            happydoclib.TRACE.verboseLevel = 1
            class FakeInfoObj(happydoclib.happydom.HappyDOM):
                pass
            info_obj = FakeInfoObj('myfake', None, 'filename.py', [])
            expected = happydoclib.path.join(
                'c:\\',
                os.path.join('tmp', 'fakedocset', 'output', 'filename.py.test')
                )
            actual = self.formatter_win32.getFullOutputNameForObject(info_obj)
            assert expected == actual, \
                   'Output name for object does not match (expect "%s", got "%s")' % \
                   (expected, actual)
            return

    def testGetFullOutputNameForObjectNone(self):
        info_obj = None
        expected = os.path.join(
            self.output_base_dir,
            'docset', 'base', 'directory',
            'index.test'
            )
        actual = self.formatter.getFullOutputNameForObject(info_obj)
        assert expected == actual, \
               ('Output name for object does not match\n'
                'Expected: "%s"\n'
                'Actual:   "%s"' % \
                (expected, actual)
                )
        return

    if os.name == 'nt':    
        def testGetFullOutputNameForObjectNoneWin32(self):
            info_obj = None
            expected = os.path.join('c:\\',
                                    'tmp',
                                    'fakedocset',
                                    'output',
                                    'docset',
                                    'base',
                                    'directory',
                                    'index.test'
                                    )
            actual = self.formatter_win32.getFullOutputNameForObject(info_obj)
            assert expected == actual, \
                   'Output name for object does not match (expected "%s", got "%s")' % \
                   (expected, actual)
            return
    
    def testGetFullOutputNameForObjectFullyQualifiedNameOneParent(self):
        import happydoclib.happydom
        class FakeInfoObj(happydoclib.happydom.HappyDOM):
            pass
        parent_obj = FakeInfoObj('myfakeparentname', None, 'myfakeparentfilename', [])
        info_obj = FakeInfoObj('myfake', parent_obj, 'filename.py', [])
        expected = os.sep + os.path.join('tmp', 'fakedocset', 'output',
                                         'docset', 'base', 'directory',
                                         'myfakeparentname', 'myfake.test'
                                         )
        actual = self.formatter.getFullOutputNameForObject(info_obj)
        assert expected == actual, \
               'Output name for object does not match\n(\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return

    def testGetFullOutputNameForFileFullyQualifiedNameRoot(self):
        filename = 'filename.py'
        expected = os.sep + os.path.join('tmp', 'fakedocset', 'output',
                                         'filename.py.test'
                                         )
        actual = self.formatter.getFullOutputNameForFile(filename)
        assert expected == actual, \
               'Output name for file does not match\n(\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return

    def testGetFullOutputNameForFileFullyQualifiedNameOneParent(self):
        filename = os.path.join('parentdir', 'filename.py')
        expected = os.sep + os.path.join('tmp', 'fakedocset', 'output',
                                         'parentdir',
                                         'filename.py.test'
                                         )
        actual = self.formatter.getFullOutputNameForFile(filename)
        assert expected == actual, \
               'Output name for file does not match\n(\n"%s"\nvs\n"%s")' % \
               (expected, actual)
        return